[Pkg-virtualbox-commits] [virtualbox] 02/06: Imported Upstream version 5.1.8-dfsg

Gianfranco Costamagna locutusofborg at moszumanska.debian.org
Wed Oct 19 07:11:55 UTC 2016


This is an automated email from the git hooks/post-receive script.

locutusofborg pushed a commit to branch master
in repository virtualbox.

commit ae4c209adb42ce1fe38d2a9509d1ced3f595216c
Author: Gianfranco Costamagna <costamagnagianfranco at yahoo.it>
Date:   Tue Oct 18 23:57:59 2016 +0200

    Imported Upstream version 5.1.8-dfsg
---
 Config.kmk                                         |   53 +-
 doc/manual/en_US/user_AdvancedTopics.xml           |   74 +
 doc/manual/en_US/user_Installation.xml             |   97 +-
 doc/manual/en_US/user_Storage.xml                  |   31 +-
 doc/manual/en_US/user_VBoxManage.xml               |    8 +-
 doc/manual/user_ChangeLogImpl.xml                  |  132 +
 include/VBox/VBoxVideo.h                           |    3 +
 include/VBox/sup.h                                 |  116 +-
 include/VBox/sup.mac                               |   11 +-
 include/iprt/err.h                                 |    2 +
 include/iprt/err.mac                               |    1 +
 include/iprt/formats/pecoff.h                      |  312 +-
 include/iprt/mangling.h                            |    7 +
 include/iprt/mp.h                                  |   31 +
 include/iprt/nt/nt.h                               |   31 +
 include/iprt/time.h                                |    2 +
 include/iprt/x86.mac                               |    2 +
 src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp  |   14 +-
 src/VBox/Additions/common/crOpenGL/DD_glc.py       |   25 +-
 src/VBox/Additions/common/crOpenGL/DD_glh.py       |   21 +-
 .../common/crOpenGL/Linux_i386_exports.py          |   83 +-
 .../common/crOpenGL/Linux_i386_exports_dri.py      |   83 +-
 .../common/crOpenGL/Linux_i386_glxapi_exports.py   |   37 +-
 src/VBox/Additions/common/crOpenGL/NULLfuncs.py    |   57 +-
 .../common/crOpenGL/SunOS_i386_exports.py          |   71 +-
 .../common/crOpenGL/SunOS_i386_exports_dri.py      |   71 +-
 .../common/crOpenGL/SunOS_i386_glxapi_exports.py   |   33 +-
 src/VBox/Additions/common/crOpenGL/cr_gl.py        |   15 +-
 src/VBox/Additions/common/crOpenGL/defs.py         |   15 +-
 src/VBox/Additions/common/crOpenGL/defs64.py       |   15 +-
 src/VBox/Additions/common/crOpenGL/entrypoints.py  |  181 +-
 .../Additions/common/crOpenGL/feedback/feedback.py |   51 +-
 .../common/crOpenGL/feedback/feedback_funcs.py     |   11 +-
 .../common/crOpenGL/feedback/feedback_state.py     |   17 +-
 .../common/crOpenGL/feedback/feedbackspu_proto.py  |   11 +-
 .../Additions/common/crOpenGL/getprocaddress.py    |   31 +-
 src/VBox/Additions/common/crOpenGL/pack/pack.py    |   27 +-
 .../common/crOpenGL/pack/packspu_beginend.py       |   29 +-
 .../common/crOpenGL/pack/packspu_flush.py          |   31 +-
 .../Additions/common/crOpenGL/pack/packspu_get.py  |  123 +-
 .../common/crOpenGL/pack/packspu_proto.py          |   11 +-
 .../common/crOpenGL/passthrough/passthrough.py     |   21 +-
 src/VBox/Additions/common/crOpenGL/stub_common.py  |   25 +-
 src/VBox/Additions/common/crOpenGL/tsfuncs.py      |   33 +-
 .../Additions/common/crOpenGL/windows_exports.py   |   63 +-
 .../common/crOpenGL/windows_getprocaddress.py      |   55 +-
 .../common/crOpenGL/windows_i386_exports.py        |   83 +-
 src/VBox/Additions/linux/drm/vbox_drv.c            |   26 +-
 src/VBox/Additions/linux/drm/vbox_drv.h            |    2 +-
 src/VBox/Additions/linux/drm/vbox_main.c           |    4 +-
 src/VBox/Additions/linux/drm/vbox_mode.c           |   20 +-
 src/VBox/Additions/linux/installer/vboxadd-x11.sh  |    7 +-
 src/VBox/Additions/linux/installer/vboxadd.sh      |    4 +-
 src/VBox/Additions/x11/VBoxClient/check3d.cpp      |   19 +
 src/VBox/Additions/x11/vboxvideo/vboxvideo.c       |    7 +
 src/VBox/Devices/Audio/AudioMixBuffer.cpp          |    2 +-
 src/VBox/Devices/Audio/AudioMixer.cpp              |  107 +-
 src/VBox/Devices/Audio/DevIchAc97.cpp              |  624 ++--
 src/VBox/Devices/Audio/DrvAudio.cpp                |  175 +-
 src/VBox/Devices/Audio/DrvHostCoreAudio.cpp        | 1350 ++++++--
 src/VBox/Devices/Audio/DrvHostDebugAudio.cpp       |   36 +-
 src/VBox/Devices/Audio/DrvHostPulseAudio.cpp       |    7 +-
 src/VBox/Devices/Bus/DevPciIch9.cpp                |   11 +-
 src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd      |  Bin 2097152 -> 2097152 bytes
 src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd      |  Bin 2097152 -> 2097152 bytes
 .../Graphics/BIOS/VBoxVgaBiosAlternative286.asm    |    6 +-
 .../Graphics/BIOS/VBoxVgaBiosAlternative286.md5sum |    2 +-
 .../Graphics/BIOS/VBoxVgaBiosAlternative386.asm    |    6 +-
 .../Graphics/BIOS/VBoxVgaBiosAlternative386.md5sum |    2 +-
 .../Graphics/BIOS/VBoxVgaBiosAlternative8086.asm   |    6 +-
 .../BIOS/VBoxVgaBiosAlternative8086.md5sum         |    2 +-
 src/VBox/Devices/Graphics/DevVGA_VBVA.cpp          |    5 +-
 src/VBox/Devices/Graphics/DevVGA_VDMA.cpp          |   25 +-
 src/VBox/Devices/Makefile.kmk                      |    6 +
 src/VBox/Devices/Network/DrvNAT.cpp                |   15 +-
 src/VBox/Devices/Network/slirp/bootp.c             |  144 +-
 .../Devices/Network/slirp/resolv_conf_parser.c     |    5 +
 src/VBox/Devices/Network/slirp/socket.c            |   34 +-
 src/VBox/Devices/Network/slirp/socket.h            |    2 +-
 .../Devices/PC/BIOS/VBoxBiosAlternative286.asm     |    4 +-
 .../Devices/PC/BIOS/VBoxBiosAlternative286.md5sum  |    2 +-
 .../Devices/PC/BIOS/VBoxBiosAlternative386.asm     |    4 +-
 .../Devices/PC/BIOS/VBoxBiosAlternative386.md5sum  |    2 +-
 .../Devices/PC/BIOS/VBoxBiosAlternative8086.asm    |    4 +-
 .../Devices/PC/BIOS/VBoxBiosAlternative8086.md5sum |    2 +-
 src/VBox/Devices/Samples/DevPlayground.cpp         |  230 ++
 src/VBox/Devices/Samples/DrvStorageFilter.cpp      |    8 +-
 src/VBox/Devices/Samples/Makefile.kmk              |    5 +-
 src/VBox/Devices/Samples/VBoxSampleDevice.cpp      |   26 +-
 src/VBox/Devices/VirtIO/Virtio.cpp                 |   22 +
 src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp   |    1 +
 .../VirtualBox/src/globals/VBoxGlobal.cpp          |    5 +
 .../VirtualBox/src/runtime/UIKeyboardHandler.cpp   |   20 +-
 .../VirtualBox/src/runtime/UIMachineView.cpp       |   14 +-
 src/VBox/GuestHost/OpenGL/error/error.py           |   25 +-
 src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py  |   81 +-
 src/VBox/GuestHost/OpenGL/packer/opcodes.py        |   52 +-
 src/VBox/GuestHost/OpenGL/packer/pack_current.py   |   33 +-
 .../GuestHost/OpenGL/packer/pack_currentheader.py  |   39 +-
 src/VBox/GuestHost/OpenGL/packer/pack_header.py    |   21 +-
 src/VBox/GuestHost/OpenGL/packer/pack_lights.c     |   82 +-
 src/VBox/GuestHost/OpenGL/packer/pack_matrices.c   |  336 +-
 src/VBox/GuestHost/OpenGL/packer/pack_program.c    |  266 +-
 .../GuestHost/OpenGL/packer/pack_regcombiner.c     |   66 +-
 src/VBox/GuestHost/OpenGL/packer/pack_swap.py      |   31 +-
 src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c   |  196 +-
 src/VBox/GuestHost/OpenGL/packer/packer.py         |  101 +-
 src/VBox/GuestHost/OpenGL/packer/packer_bbox.py    |   98 +-
 src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py   |   27 +-
 .../GuestHost/OpenGL/spu_loader/dispatchheader.py  |   39 +-
 src/VBox/GuestHost/OpenGL/spu_loader/glloader.py   |  111 +-
 src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py  |   55 +-
 src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py    |   11 +-
 src/VBox/GuestHost/OpenGL/state_tracker/convert.py |   33 +-
 .../GuestHost/OpenGL/state_tracker/dump_gen.py     |  108 +-
 .../GuestHost/OpenGL/state_tracker/gendiffcode.py  |   97 +-
 .../OpenGL/state_tracker/get_components.py         |   26 +-
 .../OpenGL/state_tracker/state_current.py          |  249 +-
 .../GuestHost/OpenGL/state_tracker/state_funcs.py  |   15 +-
 .../GuestHost/OpenGL/state_tracker/state_get.py    |  109 +-
 .../OpenGL/state_tracker/state_isenabled.py        |   43 +-
 .../OpenGL/state_tracker/state_lighting.c          |   52 +-
 src/VBox/GuestHost/OpenGL/util/debug_opcodes.py    |   22 +-
 src/VBox/HostDrivers/Support/SUPDrvGip.cpp         |  246 +-
 src/VBox/HostDrivers/Support/SUPDrvIOC.h           |    2 +-
 src/VBox/HostDrivers/Support/SUPDrvInternal.h      |   36 +
 src/VBox/HostDrivers/Support/SUPLib.cpp            |    7 +
 src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp |   29 +-
 src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp    |  169 +-
 .../VBoxNetFlt/linux/VBoxNetFlt-linux.c            |   11 +-
 .../SharedOpenGL/crserverlib/get_sizes.py          |   29 +-
 .../SharedOpenGL/crserverlib/server_dispatch.py    |   63 +-
 .../crserverlib/server_dispatch_header.py          |   11 +-
 .../SharedOpenGL/crserverlib/server_get.py         |   27 +-
 .../SharedOpenGL/crserverlib/server_retval.py      |   19 +-
 .../SharedOpenGL/crserverlib/server_simpleget.py   |   35 +-
 .../HostServices/SharedOpenGL/dlm/dlm_generated.py |    2 +-
 .../HostServices/SharedOpenGL/dlm/dlm_header.py    |    4 +-
 .../HostServices/SharedOpenGL/expando/expando.py   |    4 +-
 .../HostServices/SharedOpenGL/unpacker/unpack.py   |  149 +-
 .../SharedOpenGL/unpacker/unpack_extend.py         |   13 +-
 .../SharedOpenGL/unpacker/unpack_header.py         |   20 +-
 .../SharedOpenGL/unpacker/unpack_map.c             |  104 +-
 .../SharedOpenGL/unpacker/unpack_program.c         |  318 +-
 src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec  |    5 +
 src/VBox/Installer/linux/rpm/rules                 |   37 +-
 src/VBox/Installer/win/NLS/de_DE.wxl               |    5 +-
 src/VBox/Installer/win/NLS/en_US.wxl               |    5 +-
 src/VBox/Installer/win/NLS/fa_IR.wxl               |    5 +-
 src/VBox/Installer/win/NLS/fr_FR.wxl               |    7 +-
 src/VBox/Installer/win/NLS/it_IT.wxl               |    5 +-
 src/VBox/Installer/win/NLS/tr_TR.wxl               |    5 +-
 src/VBox/Installer/win/NLS/zh_TW.wxl               |    5 +-
 src/VBox/Installer/win/PublicProperties.wxi        |    5 +
 src/VBox/Installer/win/UserInterface.wxi           |   12 +-
 src/VBox/Installer/win/VirtualBox.wxs              |   19 +-
 src/VBox/Main/Makefile.kmk                         |    2 +-
 src/VBox/Main/glue/com.cpp                         |   13 +-
 src/VBox/Main/include/ThreadTask.h                 |   11 +-
 src/VBox/Main/include/VirtualBoxClientImpl.h       |    4 +
 src/VBox/Main/src-all/ThreadTask.cpp               |    1 +
 src/VBox/Main/src-client/ConsoleImpl2.cpp          |   16 +-
 src/VBox/Main/src-client/DisplayImpl.cpp           |   22 +
 src/VBox/Main/src-client/VirtualBoxClientImpl.cpp  |  176 ++
 src/VBox/Main/src-server/MediumImpl.cpp            |   10 +-
 src/VBox/Main/src-server/MediumLock.cpp            |    9 +
 src/VBox/Main/src-server/NATEngineImpl.cpp         |   13 +
 src/VBox/Main/src-server/SnapshotImpl.cpp          |    6 +
 src/VBox/Main/src-server/StorageControllerImpl.cpp |    1 +
 src/VBox/Main/webservice/Makefile.kmk              |   11 +-
 src/VBox/Main/webservice/vboxweb.cpp               |   19 +-
 src/VBox/Main/webservice/vboxweb.h                 |    7 +-
 src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp      |   64 +
 src/VBox/NetworkServices/NetLib/ComHostUtils.cpp   |   42 -
 src/VBox/NetworkServices/NetLib/utils.h            |    1 -
 src/VBox/RDP/client-1.8.3/ssl.c                    |   65 +
 src/VBox/RDP/client-1.8.3/tcp.c                    |   11 +
 src/VBox/Runtime/Makefile.kmk                      |   17 +-
 src/VBox/Runtime/VBox/VBoxRTDeps.cpp               |   14 +-
 src/VBox/Runtime/VBox/VBoxRTImp.def                |    1 +
 src/VBox/Runtime/common/crypto/digest-builtin.cpp  |   18 +-
 src/VBox/Runtime/common/crypto/pkix-verify.cpp     |  184 +-
 src/VBox/Runtime/common/ldr/ldrPE.cpp              |   66 +-
 src/VBox/Runtime/common/misc/lockvalidator.cpp     |    6 +-
 src/VBox/Runtime/common/time/timesup.cpp           |    4 +
 src/VBox/Runtime/common/time/timesupref.cpp        |   15 +
 src/VBox/Runtime/common/time/timesupref.h          |   24 +-
 .../Runtime/generic/mppresent-generic-online.cpp   |   61 +
 src/VBox/Runtime/include/internal/mp.h             |   82 +
 src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c      |   15 +-
 src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp    |  231 +-
 src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h      |   59 +-
 src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp          | 1194 ++++++-
 .../Runtime/r0drv/nt/mpnotification-r0drv-nt.cpp   |  189 --
 src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp       |   16 +-
 src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def |  214 ++
 src/VBox/Runtime/r3/win/VBoxRT-openssl-ose.def     | 1707 ----------
 src/VBox/Runtime/r3/win/VBoxRT-openssl-pre-1.1.def |  242 ++
 src/VBox/Runtime/r3/win/VBoxRT-openssl.def         | 3253 --------------------
 src/VBox/Runtime/r3/win/mp-win.cpp                 |  776 ++++-
 src/VBox/Runtime/testcase/Makefile.kmk             |    2 +-
 src/VBox/Runtime/testcase/tstRTMp-1.cpp            |   11 +-
 src/VBox/Storage/Makefile.kmk                      |    3 +-
 src/VBox/VMM/VMMAll/TMAllVirtual.cpp               |    2 +
 src/VBox/VMM/VMMR3/CFGM.cpp                        |    6 +-
 src/libs/Makefile.kmk                              |    6 +-
 src/libs/xpcom18a4/python/gen_python_deps.py       |    6 +-
 207 files changed, 9034 insertions(+), 8997 deletions(-)

diff --git a/Config.kmk b/Config.kmk
index b6e1d54..94b1dc8 100644
--- a/Config.kmk
+++ b/Config.kmk
@@ -208,7 +208,7 @@ VBOX_VERSION_MINOR = 1
 # This is the current build number. It should be increased every time we publish a
 # new build. The define is available in every source file. Only even build numbers
 # will be published, odd numbers are set during development.
-VBOX_VERSION_BUILD = 6
+VBOX_VERSION_BUILD = 8
 # The raw version string. This *must not* contain any other information/fields than
 # major, minor and build revision (as it is now) -- also will be used for host/guest version
 # comparison.
@@ -747,6 +747,8 @@ VBOX_WITH_EXTPACK_VBOXDTRACE = 1
 
 ## @name Misc
 ## @{
+# Enable to compile with OpenSSL 1.0 (only relevant for Windows, see src/VBox/Runtime/Makefile.kmk)
+#VBOX_WITH_OPENSSL_PRE_1_1 = 1
 # Enable Seamless mode
 VBOX_X11_SEAMLESS_GUEST = 1
 # Enables all the doxgen bits.
@@ -1730,7 +1732,8 @@ ifndef VBOX_BLD_PYTHON
   				   python-not-found.exe)
  else
   VBOX_BLD_PYTHON := $(firstword $(which python2.7$(HOSTSUFF_EXE)) $(which python2.6$(HOSTSUFF_EXE)) \
-                                 $(which python$(HOSTSUFF_EXE)) python$(HOSTSUFF_EXE))
+                                 $(which python$(HOSTSUFF_EXE)) $(which python3$(HOSTSUFF_EXE)) \
+				   python-not-found)
  endif
 endif
 
@@ -1944,7 +1947,7 @@ VBOX_MAKESELF  ?= $(KBUILD_DEVTOOLS)/common/makeself/v2.1.5/makeself.sh
 VBOX_PATH_HTML_HELP_WORKSHOP ?= $(KBUILD_DEVTOOLS)/win.x86/HTML_Help_Workshop/v1.3/
 
 # Path to the null soft installer.
-VBOX_PATH_NSIS ?= $(KBUILD_DEVTOOLS)/win.x86/nsis/v2.46-log-nsscm-r1
+VBOX_PATH_NSIS ?= $(KBUILD_DEVTOOLS)/win.x86/nsis/v2.51-log-nsscm-r1
 
 # Path to AutoIt3.
 VBOX_PATH_AUTOIT3 ?= $(KBUILD_DEVTOOLS)/win.x86/autoit/v3.2.10.0
@@ -2437,9 +2440,9 @@ ifeq ($(KBUILD_HOST),win)
  VBOX_GCC32_CHECK_CXX = $(2)
 else
  VBOX_GCC_CHECK_EX_CC = $(shell \
-    if $(1) $(subst -Wno-,-W,$(2)) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi; )
+    if $(1) $(subst -Wno-,-W,$(2)) -Werror -c -o /dev/null -xc   $(PATH_OUT)/DynamicConfig.c   > /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi; )
  VBOX_GCC_CHECK_EX_CXX = $(shell \
-    if $(1) $(subst -Wno-,-W,$(2)) -S -o /dev/null -xc++ /dev/null > /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi; )
+    if $(1) $(subst -Wno-,-W,$(2)) -Werror -c -o /dev/null -xc++ $(PATH_OUT)/DynamicConfig.cpp > /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi; )
  VBOX_GCC_CHECK_EX_LD = $(shell \
     if $(1) -Wl,$(2) $(if $(eq $(KBUILD_HOST),darwin),-Wl$(COMMA)-u$(COMMA)start -Wl$(COMMA)-undefined$(COMMA)dynamic_lookup,) \
             -nostdlib -o /dev/null -xc /dev/null > /dev/null 2>&1; \
@@ -2528,6 +2531,11 @@ endif
 VBOX_PYLINT_FIGURE_VERSION = $(shell $(1) --version 2> /dev/null \
 	| $(SED_EXT) -n -e 's|^ *pylint *\([0-9][0-9]*\).\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$(DOLLAR)|$$(expr \1 * 10000 + \2 * 100 + \3)|p' )
 
+# Test C and C++ files.
+$(PATH_OUT)/DynamicConfig.c $(PATH_OUT)/DynamicConfig.cpp:
+	$(QUIET)$(MKDIR) -p $(@D)
+	$(QUIET)$(APPEND) -tn "$@" "int foobar(void)" "{" "    return 42;" "}" ""
+
 # No $(QUIET) here as it's interesting to see what goes into the file.
 $(PATH_OUT)/DynamicConfig.kmk: \
 		$(PATH_ROOT)/Config.kmk \
@@ -2538,7 +2546,8 @@ $(PATH_OUT)/DynamicConfig.kmk: \
 		$(VBOX_GCC32_PATH_CC) \
 		$(VBOX_GCC32_PATH_CXX) \
 		$(if-expr "$(KBUILD_HOST).$(KBUILD_HOST_ARCH)" == "solaris.amd64" && $(KBUILD_HOST_VERSION_MINOR) >= 11 \
-			, /platform/i86pc/kernel/$(KBUILD_HOST_ARCH)/unix,)
+			, /platform/i86pc/kernel/$(KBUILD_HOST_ARCH)/unix,) \
+        	| $(PATH_OUT)/DynamicConfig.c $(PATH_OUT)/DynamicConfig.cpp
 	$(call MSG_GENERATE,,$@,)
 	$(QUIET)$(RM) -f '$@'
 	$(QUIET)$(MKDIR) -p $(@D)
@@ -2562,11 +2571,8 @@ $(PATH_OUT)/DynamicConfig.kmk: \
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-delete-non-virtual-dtor    ?= $(call VBOX_GCC_CHECK_CXX,-Wno-delete-non-virtual-dtor,)'
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-int-to-pointer-cast        ?= $(call VBOX_GCC_CHECK_CC,-Wno-int-to-pointer-cast,)'
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-invalid-offsetof           ?= $(call VBOX_GCC_CHECK_CXX,-Wno-invalid-offsetof,)'
-if $(KBUILD_TARGET) != "darwin" || !defined(VBOX_WITH_NEW_XCODE) ## @todo somthing goes entirely sideways with the detection. clang doesn't know the option, but only complains when we use it in webservices/Makefile.kmk!
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-literal-suffix             ?= $(call VBOX_GCC_CHECK_CXX,-Wno-literal-suffix,)'
-else
-	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-literal-suffix             ?='
-endif
+	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-misleading-indentation     ?= $(call VBOX_GCC_CHECK_CC,-Wno-misleading-indentation,)'
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-missing-field-initializers ?= $(call VBOX_GCC_CHECK_CC,-Wno-missing-field-initializers,)'
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-pointer-to-int-cast        ?= $(call VBOX_GCC_CHECK_CC,-Wno-pointer-to-int-cast,)'
 	$(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-variadic-macros   ?= $(call VBOX_GCC_CHECK_CXX,-Wno-variadic-macros,)'
@@ -3572,7 +3578,7 @@ if1of ($(KBUILD_TARGET), os2 win) # Not required on solaris.
 endif
 
 SDK_VBOX_OPENSSL      = Only for VBoxRT and/or statically linked programs.
-SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-headers/include
+SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-1.1.0-headers/include
 SDK_VBOX_OPENSSL_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
 SDK_VBOX_OPENSSL_ORDERDEPS ?= $(crypto-headers_1_TARGET)
 SDK_VBOX_OPENSSL_LIBS ?= \
@@ -3580,7 +3586,7 @@ SDK_VBOX_OPENSSL_LIBS ?= \
 	$(PATH_STAGE_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
 
 SDK_VBOX_OPENSSL-x86      = Only for VBoxRT and/or statically linked programs.
-SDK_VBOX_OPENSSL-x86_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-headers/include
+SDK_VBOX_OPENSSL-x86_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-1.1.0-headers/include
 SDK_VBOX_OPENSSL-x86_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
 SDK_VBOX_OPENSSL-x86_ORDERDEPS ?= $(crypto-headers_1_TARGET)
 SDK_VBOX_OPENSSL-x86_LIBS ?= \
@@ -3593,21 +3599,14 @@ if "$(SDK_VBOX_OPENSSL_INCS)" == "$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)"
  SDK_VBOX_OPENSSL2_LIBS = $(NO_SUCH_VARIABLE)
 endif
 
-SDK_VBoxOpenSslExtPack                 = Internal use only.
-SDK_VBoxOpenSslExtPack_INCS            = $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
-SDK_VBoxOpenSslExtPack_ORDERDEPS       = $(crypto-headers_1_TARGET)
-SDK_VBoxOpenSslExtPack_LIBS    = \
-	$(PATH_STAGE_LIB)/VBoxExtPack-libssl$(VBOX_SUFF_LIB) \
-	$(PATH_STAGE_LIB)/VBoxExtPack-libcrypto$(VBOX_SUFF_LIB)
-
 ifdef VBOX_WITH_LIBCURL
 SDK_VBOX_LIBCURL       = .
-SDK_VBOX_LIBCURL_INCS ?= $(PATH_ROOT)/src/libs/curl-7.47.0/include
+SDK_VBOX_LIBCURL_INCS ?= $(PATH_ROOT)/src/libs/curl-7.50.3/include
 SDK_VBOX_LIBCURL_LIBS ?= $(PATH_STAGE_LIB)/VBox-libcurl$(VBOX_SUFF_LIB)
 SDK_VBOX_LIBCURL_DEFS ?= BUILDING_LIBCURL
 
 SDK_VBOX_LIBCURL-x86           = .
-SDK_VBOX_LIBCURL-x86_INCS     ?= $(PATH_ROOT)/src/libs/curl-7.47.0/include
+SDK_VBOX_LIBCURL-x86_INCS     ?= $(PATH_ROOT)/src/libs/curl-7.50.3/include
 SDK_VBOX_LIBCURL-x86_LIBS.x86 ?= $(PATH_STAGE_LIB)/VBox-libcurl-x86$(VBOX_SUFF_LIB)
 SDK_VBOX_LIBCURL-x86_DEFS     ?= BUILDING_LIBCURL
 endif
@@ -5658,6 +5657,16 @@ ifdef VBOX_WITH_EXTPACK
   TEMPLATE_VBoxR3ExtPackPuel_INST = $(INST_EXTPACK_PUEL)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
   TEMPLATE_VBoxR3ExtPackPuel_DEFS = $(TEMPLATE_VBoxR3ExtPack_DEFS) VBOX_IN_PUEL_EXTPACK
 
+  TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl = For the ring-3 context modules in the PUEL extension pack using ExtPack OpenSSL.
+  TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl_EXTENDS = VBoxR3ExtPackPuel
+  TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl_INCS = \
+  	$(TEMPLATE_VBoxR3ExtPack_INCS) \
+  	$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
+  TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl_LIBS = \
+  	$(PATH_STAGE_LIB)/VBoxExtPack-libssl$(VBOX_SUFF_LIB) \
+  	$(PATH_STAGE_LIB)/VBoxExtPack-libcrypto$(VBOX_SUFF_LIB) \
+  	$(TEMPLATE_VBoxR3ExtPack_LIBS) # Must come after the two libraries or we'll pick up SSL from VBoxRT!
+
   TEMPLATE_VBoxR0ExtPackPuel = For the ring-0 context modules in the PUEL extension pack.
   TEMPLATE_VBoxR0ExtPackPuel_EXTENDS = VBoxR0ExtPack
   TEMPLATE_VBoxR0ExtPackPuel_INST = $(INST_EXTPACK_PUEL)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
@@ -6847,7 +6856,7 @@ endif
 SVN                    ?= svn$(HOSTSUFF_EXE)
 VBOX_SVN_REV_KMK        = $(PATH_OUT)/revision.kmk
 ifndef VBOX_SVN_REV
- VBOX_SVN_REV_FALLBACK := $(patsubst %:,,  $Rev: 110634 $  )
+ VBOX_SVN_REV_FALLBACK := $(patsubst %:,,  $Rev: 111374 $  )
  VBOX_SVN_DEP          := $(firstword $(wildcard $(PATH_ROOT)/.svn/wc.db $(abspath $(PATH_ROOT)/../.svn/wc.db) $(abspath $(PATH_ROOT)/../../.svn/wc.db) $(PATH_ROOT)/.svn/entries))
  ifeq ($(which $(SVN)),)
   VBOX_SVN_DEP         :=
diff --git a/doc/manual/en_US/user_AdvancedTopics.xml b/doc/manual/en_US/user_AdvancedTopics.xml
index f450f1c..0fd9ec0 100644
--- a/doc/manual/en_US/user_AdvancedTopics.xml
+++ b/doc/manual/en_US/user_AdvancedTopics.xml
@@ -4287,4 +4287,78 @@ VBoxManage setextradata "VM name" VBoxInternal/CPUM/SSE4.2 1</screen>
     (could be hidden in the mixer settings) and that it isn't muted.</para>
   </sect1>
 
+  <sect1 id="usbip">
+    <title>Accessing USB devices exposed over the network with USB/IP</title>
+
+    <para>Starting with 5.1.0, VirtualBox supports passing through USB
+    devices which are exposed over the network using the USB over IP protocol
+    without the need to configure the client side provided by the kernel and
+    usbip tools. Furthermore, this feature works with VirtualBox running on any
+    supported host, rather than just Linux alone - as is the case with the official
+    client.</para>
+
+    <para>To enable support for passing through USB/IP devices, the device server exporting
+    the devices must be added with the following command:
+    <screen>VBoxManage usbdevsource add "Unique name" --backend "USBIP" --address "Device server[:port]"</screen>
+    USB devices exported on the device server are then accessible through the GUI
+    or VBoxManage, like any USB devices attached locally. This can be used multiple times
+    to access different device servers.</para>
+
+    <para>To remove a device server, the following command can be used:
+      <screen>VBoxManage usbdevsource remove "Unique name"</screen>
+    </para>
+
+    <sect2 id="usbip-setup-server">
+      <title>Setting up USB/IP support on a Linux system</title>
+
+      <para>This section gives a brief overview on how to set up a Linux based system
+      to act as a USB device server. The system on the server requires that the
+      <computeroutput>usbip-core.ko</computeroutput> and
+      <computeroutput>usbip-host.ko</computeroutput> kernel drivers
+      are available, and that the USB/IP tools package is installed.
+      The particular installation method for the necessary tools depends on which 
+      distribution is used.
+      For example, for Debian based systems - the following command should be used to 
+      install the required tools:
+      <screen>apt-get install usbip-utils</screen></para>
+      <para>To check whether the necessary tools are already installed use
+      the following command:
+      <screen>
+$ usbip list -l
+      </screen></para>
+      <para>
+      which should produce output similar to that shown in the example below:
+      <screen>
+ - busid 4-2 (0bda:0301)
+   Realtek Semiconductor Corp. : multicard reader (0bda:0301)
+
+ - busid 5-1 (046d:c52b)
+   Logitech, Inc. : Unifying Receiver (046d:c52b)
+      </screen></para>
+
+      <para>If everything is installed, the USB/IP server needs to be started as
+      <computeroutput>root</computeroutput> using the following command:
+      <screen>usbipd -D</screen>
+      Refer to the documentation for the installed distribution to determine how to start the
+      service when the system boots.</para>
+
+      <para>By default, no device on the server is exported - and this must be done manually
+      for each device. To export a device use: 
+      <screen>usbip bind -b "bus identifier"</screen>
+      To export the multicard reader from above, for example  - use:
+      <screen>usbip bind -b 4-2</screen></para>
+    </sect2>
+
+    <sect2 id="usbip-security">
+      <title>Security considerations</title>
+
+      <para>The communication between the server and client is unencrypted and
+      there is no authorization required to access exported devices. An attacker
+      might sniff sensitive data or gain control over a device. To mitigate this
+      risk, the device should be exposed over a local network to which only trusted
+      clients have access. To access the device remotely over a public network,
+      a VPN solution should be used to provide the required level of security protection.</para>
+    </sect2>
+  </sect1>
+
 </chapter>
diff --git a/doc/manual/en_US/user_Installation.xml b/doc/manual/en_US/user_Installation.xml
index 127c199..bb708ef 100644
--- a/doc/manual/en_US/user_Installation.xml
+++ b/doc/manual/en_US/user_Installation.xml
@@ -353,68 +353,75 @@
     </sect2>
 
     <sect2 id="externalkernelmodules">
-      <title>The VirtualBox kernel module</title>
-
-      <para>VirtualBox uses a special kernel module called
-      <computeroutput>vboxdrv</computeroutput> to perform physical memory
-      allocation and to gain control of the processor for guest system
-      execution. Without this kernel module, you can still use the VirtualBox
-      manager to configure virtual machines, but they will not start. In
-      addition, there are the network kernel modules
+      <title>The VirtualBox driver modules</title>
+
+      <para>In order to run other operating systems in virtual machines
+      alongside your main operating system, VirtualBox needs to integrate
+      very tightly into the system.  To do this it installs a "driver"
+      module called <computeroutput>vboxdrv</computeroutput> which does
+      a lot of that work into the system kernel, which is the part of
+      the operating system which controls your processor and physical
+      hardware. Without this kernel module, you can still use the
+      VirtualBox manager to configure virtual machines, but they will not
+      start. It also installs network drivers called
       <computeroutput>vboxnetflt</computeroutput> and
-      <computeroutput>vboxnetadp</computeroutput> which are required for the
-      more advanced networking features of VirtualBox.</para>
-
-      <para>The modules will be built automatically during installation or
-      after kernel updates if your Linux system is prepared for building
-      external kernel modules.</para>
-
-      <para>Most Linux distributions can be set up simply by installing
-      the right packages - normally, these will be the GNU compiler
-      (GCC), GNU Make (make) and packages containing header files for
+      <computeroutput>vboxnetadp</computeroutput> which let virtual machines
+      make more use of your computer's network capabilities and are needed
+      for any virtual machine networking beyond the basic "NAT" mode.</para>
+
+      <para>Since distributing driver modules separately from the kernel
+      is not something which Linux supports well, we create the modules
+      on the system where they will be used.  This usually means first
+      installing software packages from the distribution which are needed
+      for the "build" process.  Normally, these will be the GNU compiler
+      (GCC), GNU Make (make) and packages containing "header files" for
       your kernel - and making sure that all system updates are
       installed and that the system is running the most up-to-date
-      kernel included in the distribution. <emphasis>The version numbers
-      of the header file packages must be the same as that of the kernel
-      you are using.</emphasis></para>
+      kernel included in the distribution. <emphasis>The running kernel
+      and the header files must be updated to matching versions.</emphasis>
+      We will give some instructions for common distributions.  For most
+      of them you will want to start by finding the version name of your
+      kernel using the command
+      <computeroutput>uname -r</computeroutput> in a terminal.  They
+      assume that you have not changed too much from the original
+      installation, particularly not installed a different kernel type.
+      If you have then you will need to determine yourself what to set
+      up.</para>
 
       <itemizedlist>
         <listitem>
-          <para>With Debian and Ubuntu releases, you must install the
-          right version of the
-          <computeroutput>linux-headers</computeroutput> and if it
-          exists the <computeroutput>linux-kbuild</computeroutput>
-          package. Current Ubuntu releases should have the right
+          <para>With Debian and Ubuntu-based distributions, you
+          must install the right version of the
+          <computeroutput>linux-headers</computeroutput>, usually
+          whichever of <computeroutput>linux-headers-generic
+          </computeroutput>, <computeroutput>linux-headers-amd64
+          </computeroutput>, <computeroutput>linux-headers-i686
+          </computeroutput> or <computeroutput>linux-headers-i686-pae
+          </computeroutput> best matches the kernel version name;
+          and if it exists the <computeroutput>linux-kbuild
+          </computeroutput>
+          package. Basic Ubuntu releases should have the right
           packages installed by default.</para>
         </listitem>
 
         <listitem>
-          <para>In even older Debian and Ubuntu releases, you must
-          install the right version of the
-          <computeroutput>kernel-headers</computeroutput>
-          package.</para>
-        </listitem>
-
-        <listitem>
-          <para>On Fedora and Redhat systems, the package is
+          <para>On Fedora, Redhat, Oracle Linux and many other
+          RPM-based systems, the kernel version sometimes has
+          a code of letters or a word close to the end of the
+          version name, for example "uek" for the Oracle
+          Enterprise kernel or "default" or "desktop" for the
+          standard SUSE kernels.  In this case the package name is
+          <computeroutput>kernel-uek-devel</computeroutput> or
+          equivalent.  If there is no such code, it is usually
           <computeroutput>kernel-devel</computeroutput>.</para>
         </listitem>
 
         <listitem>
-          <para>On SUSE and openSUSE Linux, you must install the right
-          versions of the <computeroutput>kernel-source</computeroutput>
+          <para>On older SUSE and openSUSE Linux, you must install
+          the <computeroutput>kernel-source</computeroutput>
           and <computeroutput>kernel-syms</computeroutput>
           packages.</para>
         </listitem>
-
-        <listitem>
-          <para>If you have built your own kernel, you will need to make
-          sure that you also installed all the required header and other
-          files for building external modules to the right locations.
-          The details of how to do this will depend on how you built
-          your kernel, and if you are unsure you should consult the
-          documentation which you followed to do so.</para>
-        </listitem>
       </itemizedlist>
 
       <para>If you suspect that something has gone wrong with module installation,
diff --git a/doc/manual/en_US/user_Storage.xml b/doc/manual/en_US/user_Storage.xml
index 9170036..97d5d5d 100644
--- a/doc/manual/en_US/user_Storage.xml
+++ b/doc/manual/en_US/user_Storage.xml
@@ -35,19 +35,19 @@
   section.</para>
 
   <sect1 id="harddiskcontrollers">
-    <title>Hard disk controllers: IDE, SATA (AHCI), SCSI, SAS, USB MSD</title>
+    <title>Hard disk controllers: IDE, SATA (AHCI), SCSI, SAS, USB MSD, NVMe</title>
 
     <para>In a real PC, hard disks and CD/DVD drives are connected to a device
     called hard disk controller which drives hard disk operation and data
     transfers. VirtualBox can emulate the five most common types of hard disk
     controllers typically found in today's PCs: IDE, SATA (AHCI), SCSI,
-    SAS and USB-based mass storage devices.<footnote>
+    SAS, USB-based and NVMe mass storage devices.<footnote>
         <para>SATA support was added with VirtualBox 1.6; experimental SCSI
         support was added with 2.1 and fully implemented with 2.2. Generally,
         storage attachments were made much more flexible with VirtualBox 3.1;
         see below. Support for the LSI Logic SAS controller was added with
         VirtualBox 3.2; USB mass storage devices are supported since
-        VirtualBox 5.0.</para>
+        VirtualBox 5.0; NVMe controller support was added with VirtualBox 5.1.</para>
       </footnote><itemizedlist>
         <listitem>
           <para><emphasis role="bold">IDE (ATA)</emphasis> controllers are a
@@ -205,10 +205,28 @@
           as virtual storage controller. Each disk attached to the controller
           appears as a dedicated USB device to the guest.</para>
           <warning>
-            <para>Booting from drives attached via USB is not supported as the
+            <para>Booting from drives attached via USB is when EFI is used as the
               BIOS lacks USB support.</para>
           </warning>
         </listitem>
+
+        <listitem>
+          <para><emphasis role="bold">Non volatile memory express (NVMe)</emphasis>
+          is a very recent standard which emerged in 2011 connecting non volatile
+          memory (NVM) directly over PCI express to lift the bandwidth limitation
+          of the previously used SATA protocol for SSDs. Unlike other standards
+          the command set is very simple to achieve maximum throughput and is
+          not compatible with ATA or SCSI. Operating systems need to support NVMe
+          devices to make use of them. For example Windows 8.1 added native NVMe
+          support, for Windows 7 native support was added with an update.
+          <footnote>
+            <para>The NVMe controller is part of the extension pack.</para>
+          </footnote></para>
+          <warning>
+            <para>Booting from drives attached via NVMe is only supported when
+            EFI is used as the BIOS lacks the appropriate driver.</para>
+          </warning>
+        </listitem>
       </itemizedlist></para>
 
     <para>In summary, VirtualBox gives you the following categories of virtual
@@ -238,6 +256,11 @@
           <para>eight slots attached to the virtual USB controller, if enabled and
           supported by the guest operating system.</para>
         </listitem>
+
+        <listitem>
+          <para>up to 255 slots attached to the NVMe controller, if enabled and
+          supported by the guest operating system.</para>
+        </listitem>
       </orderedlist></para>
 
     <para>Given this large choice of storage controllers, you may ask yourself
diff --git a/doc/manual/en_US/user_VBoxManage.xml b/doc/manual/en_US/user_VBoxManage.xml
index 3909e82..8585294 100644
--- a/doc/manual/en_US/user_VBoxManage.xml
+++ b/doc/manual/en_US/user_VBoxManage.xml
@@ -1273,9 +1273,11 @@ UUID="457af700-bc0a-4258-aa3c-13b03da171f2"
         </listitem>
 
         <listitem>
-          <para><computeroutput>--audio none|null|oss|alsa|pulse</computeroutput>: With
-          this option, you can set whether the VM should have audio
-          support, and if so - which type.</para>
+          <para><computeroutput>--audio none|null|dsound|oss|alsa|pulse|coreaudio</computeroutput>:
+          With this setting, you can specify whether the VM should have audio support, and
+          – if so – which type. The list of supported audio types depends on the
+          host and can be determined with <computeroutput>VBoxManage modifyvm</computeroutput>.
+        </para>
         </listitem>
 
         <listitem>
diff --git a/doc/manual/user_ChangeLogImpl.xml b/doc/manual/user_ChangeLogImpl.xml
index 74130ae..ea202d5 100644
--- a/doc/manual/user_ChangeLogImpl.xml
+++ b/doc/manual/user_ChangeLogImpl.xml
@@ -3,6 +3,138 @@
 <chapter> <!-- HACK ALERT! Seems we must have a single top level element for xi:include to work.
                            So, we use chapter and xpointer="xpointer(/chapter/)" with xi:include. -->
   <sect1>
+    <title>Version 5.1.8 (2016-10-18)</title>
+
+    <para>This is a maintenance release. The following items were fixed and/or
+      added:</para>
+
+    <itemizedlist>
+
+      <listitem>
+        <para>GUI: fixed keyboard shortcut handling regressions (Mac OS X hosts
+          only; bugs #15937 and #15938)</para>
+      </listitem>
+
+      <listitem>
+        <para>GUI: fixed keyboard handling regression for separate UI (Windows
+          hosts only; bugs #15928)</para>
+      </listitem>
+
+      <listitem>
+        <para>NAT: don't exceed the maximum number of "search" suffixes.
+          Patch from bug #15948.</para>
+      </listitem>
+
+      <listitem>
+        <para>NAT: fixed parsing of port-forwarding rules with a name which
+          contains a slah (bug #16002)</para>
+      </listitem>
+
+      <listitem>
+        <para>NAT Network: when the host has only loopback nameserver
+          that cannot be mapped to the guests (e.g. dnsmasq running on
+          127.0.1.1), make DHCP supply NAT Network DNS proxy as
+          nameserver.</para>
+      </listitem>
+
+      <listitem>
+        <para>Bridged Network: prevent flooding syslog with packet allocation
+          error messages (bug #15569)</para>
+      </listitem>
+
+      <listitem>
+        <para>Audio: now using Audio Queues on Mac OS X hosts</para>
+      </listitem>
+
+      <listitem>
+        <para>Audio: fixed recording with the PulseAudio backend (5.1 regression)</para>
+      </listitem>
+
+      <listitem>
+        <para>Audio: various bugfixes</para>
+      </listitem>
+
+      <listitem>
+        <para>Snapshots: fixed regression in 5.1.4 for deleting snapshots with
+          several disks (bug #15831)</para>
+      </listitem>
+
+      <listitem>
+        <para>Snapshots: crash fix and better error reporting when snapshot
+          deletion failed</para>
+      </listitem>
+
+      <listitem>
+        <para>Storage: some fixes for the NVMe emulation with Windows guests</para>
+      </listitem>
+
+      <listitem>
+        <para>API: fixed initialization of SAS controllers (bug #15972)</para>
+      </listitem>
+
+      <listitem>
+        <para>Build system: make it possible to build VBox on systems which
+          default to Python 3</para>
+      </listitem>
+
+      <listitem>
+        <para>Windows hosts: detect certain cases of
+          <emphasis>REGDB_E_CLASSNOTREG</emphasis> errors and print a helpful
+          error message</para>
+      </listitem>
+
+      <listitem>
+        <para>Windows hosts: adapted to changes in Windows 10 build 14901
+          (bug #15944)</para>
+      </listitem>
+
+      <listitem>
+        <para>Windows hosts: better support for processor groups on Windows 7
+          and later which is required on certain hosts with many CPUs</para>
+      </listitem>
+
+      <listitem>
+        <para>Windows installer / Additions: added option to prevent creating
+          of start menu items (bug #15922)</para>
+      </listitem>
+
+      <listitem>
+        <para>Windows Additions / VGA: if the guest's power management turns
+          a virtual screen off, blank the corresponding VM window rather than
+          hide the window</para>
+      </listitem>
+
+      <listitem>
+        <para>Windows Additions: fixed a generic bug which could lead to
+          freezing shared folders (bug #15662)</para>
+      </listitem>
+
+      <listitem>
+        <para>Linux hosts / guests: fix for kernels with
+          <emphasis>CONFIG_CPUMASK_OFFSTACK</emphasis> set (bug #16020)</para>
+      </listitem>
+
+      <listitem>
+        <para>Linux Additions: don't require all virtual consoles be in text
+          mode. This should fix cases when the guest is booted with a graphical
+          boot screen (bug #15683)</para>
+      </listitem>
+
+      <listitem>
+        <para>Linux Additions: added depmod overrides for the vboxguest and vboxsf
+          kernel modules to fix conflicts with modules shipped by certain Linux
+          distributions</para>
+      </listitem>
+
+      <listitem>
+        <para>X11 Additions: disable 3D on the guest if the host does not
+           provide enough capabilities (bug #15860)</para>
+      </listitem>
+
+    </itemizedlist>
+  </sect1>
+
+  <sect1>
     <title>Version 5.1.6 (2016-09-12)</title>
 
     <para>This is a maintenance release. The following items were fixed and/or
diff --git a/include/VBox/VBoxVideo.h b/include/VBox/VBoxVideo.h
index e08e3f3..337ef5b 100644
--- a/include/VBox/VBoxVideo.h
+++ b/include/VBox/VBoxVideo.h
@@ -993,6 +993,9 @@ typedef struct VBVACMDVBVAFLUSH
 /** The virtual monitor has been blanked by the guest and should be blacked
  * out by the host. */
 #define VBVA_SCREEN_F_BLANK    0x0004
+/** The virtual monitor has been blanked by the guest and should be blacked
+ * out by the host using the previous mode values for width. height, etc. */
+#define VBVA_SCREEN_F_BLANK2   0x0008
 
 typedef struct VBVAINFOSCREEN
 {
diff --git a/include/VBox/sup.h b/include/VBox/sup.h
index 330c0d8..a3b3eaf 100644
--- a/include/VBox/sup.h
+++ b/include/VBox/sup.h
@@ -229,61 +229,85 @@ typedef struct SUPGIPCPU
      * thusly that odd numbers indicates update in progress, while even numbers
      * indicate stable data. Use this to make sure that the data items you fetch
      * are consistent. */
-    volatile uint32_t   u32TransactionId;
+    volatile uint32_t       u32TransactionId;
     /** The interval in TSC ticks between two NanoTS updates.
      * This is the average interval over the last 2, 4 or 8 updates + a little slack.
      * The slack makes the time go a tiny tiny bit slower and extends the interval enough
      * to avoid ending up with too many 1ns increments. */
-    volatile uint32_t   u32UpdateIntervalTSC;
+    volatile uint32_t       u32UpdateIntervalTSC;
     /** Current nanosecond timestamp. */
-    volatile uint64_t   u64NanoTS;
+    volatile uint64_t       u64NanoTS;
     /** The TSC at the time of u64NanoTS. */
-    volatile uint64_t   u64TSC;
+    volatile uint64_t       u64TSC;
     /** Current CPU Frequency. */
-    volatile uint64_t   u64CpuHz;
+    volatile uint64_t       u64CpuHz;
     /** The TSC delta with reference to the master TSC, subtract from RDTSC. */
-    volatile int64_t    i64TSCDelta;
+    volatile int64_t        i64TSCDelta;
     /** Number of errors during updating.
      * Typical errors are under/overflows. */
-    volatile uint32_t   cErrors;
+    volatile uint32_t       cErrors;
     /** Index of the head item in au32TSCHistory. */
-    volatile uint32_t   iTSCHistoryHead;
+    volatile uint32_t       iTSCHistoryHead;
     /** Array of recent TSC interval deltas.
      * The most recent item is at index iTSCHistoryHead.
      * This history is used to calculate u32UpdateIntervalTSC.
      */
-    volatile uint32_t   au32TSCHistory[8];
+    volatile uint32_t       au32TSCHistory[8];
     /** The interval between the last two NanoTS updates. (experiment for now) */
-    volatile uint32_t   u32PrevUpdateIntervalNS;
+    volatile uint32_t       u32PrevUpdateIntervalNS;
 
     /** Reserved for future per processor data. */
-    volatile uint32_t   au32Reserved0[5];
-
+    volatile uint32_t       u32Reserved;
     /** The TSC value read while doing TSC delta measurements across CPUs. */
-    volatile uint64_t   u64TSCSample;
-
+    volatile uint64_t       u64TSCSample;
     /** Reserved for future per processor data. */
-    volatile uint32_t   au32Reserved1[1];
+    volatile uint32_t       au32Reserved1[3];
 
-    /** @todo Add topology/NUMA info. */
     /** The CPU state. */
     SUPGIPCPUSTATE volatile enmState;
     /** The host CPU ID of this CPU (the SUPGIPCPU is indexed by APIC ID). */
     RTCPUID                 idCpu;
     /** The CPU set index of this CPU. */
     int16_t                 iCpuSet;
+    /** CPU group number (always zero, except on windows). */
+    uint16_t                iCpuGroup;
+    /** CPU group member number (same as iCpuSet, except on windows). */
+    uint16_t                iCpuGroupMember;
     /** The APIC ID of this CPU. */
     uint16_t                idApic;
+    /** @todo Add topology/NUMA info. */
+    uint32_t                iReservedForNumaNode;
 } SUPGIPCPU;
 AssertCompileSize(RTCPUID, 4);
 AssertCompileSize(SUPGIPCPU, 128);
 AssertCompileMemberAlignment(SUPGIPCPU, u64NanoTS, 8);
 AssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8);
+AssertCompileMemberAlignment(SUPGIPCPU, u64TSCSample, 8);
 
 /** Pointer to per cpu data.
  * @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
 typedef SUPGIPCPU *PSUPGIPCPU;
 
+/**
+ * CPU group information.
+ * @remarks Windows only.
+ */
+typedef struct SUPGIPCPUGROUP
+{
+    /** Current number of CPUs in this group. */
+    uint16_t volatile       cMembers;
+    /** Maximum number of CPUs in the group. */
+    uint16_t                cMaxMembers;
+    /** The CPU set index of the members. This table has cMaxMembers entries.
+     * @note For various reasons, entries from cMembers and up to cMaxMembers are
+     *       may change as the host OS does set dynamic assignments during CPU
+     *       hotplugging. */
+    int16_t                 aiCpuSetIdxs[1];
+} SUPGIPCPUGROUP;
+/** Pointer to a GIP CPU group structure. */
+typedef SUPGIPCPUGROUP *PSUPGIPCPUGROUP;
+/** Pointer to a const GIP CPU group structure. */
+typedef SUPGIPCPUGROUP const *PCSUPGIPCPUGROUP;
 
 /**
  * The rules concerning the applicability of SUPGIPCPU::i64TscDelta.
@@ -313,6 +337,12 @@ typedef enum SUPGIPUSETSCDELTA
 
 
 /** @name SUPGIPGETCPU_XXX - methods that aCPUs can be indexed.
+ *
+ * @note    Linux offers information via selector 0x78, and Windows via selector
+ *          0x53.  But since they both support RDTSCP as well, and because most
+ *          CPUs now have RDTSCP, we prefer it over LSL.  We can implement more
+ *          alternatives if it becomes necessary.
+ *
  * @{
  */
 /** Use ASMGetApicId (or equivalent) and translate the result via
@@ -334,10 +364,26 @@ typedef enum SUPGIPUSETSCDELTA
  * value in the IDT limit.  The masking is a precaution against what linux
  * does with RDTSCP. */
 #define SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS   RT_BIT_32(2)
-/* Linux also offers information via selector 0x78, but we'll settle for
-   RDTSCP for now. */
+/** Windows specific RDTSCP variant, where CH gives you the group and CL gives
+ * you the CPU number within that group.
+ *
+ * Use SUPGLOBALINFOPAGE::aidFirstCpuFromCpuGroup to get the group base CPU set
+ * index, then translate the sum of thru aiCpuFromCpuSetIdx to find the aCPUs
+ * entry.
+ *
+ * @note The group number is actually 16-bit wide (ECX[23:8]), but we simplify
+ *       it since we only support 256 CPUs/groups at the moment.
+ */
+#define SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL RT_BIT_32(3)
 /** @} */
 
+/** @def SUPGIP_MAX_CPU_GROUPS
+ * Maximum number of CPU groups.  */
+#if RTCPUSET_MAX_CPUS >= 256
+# define SUPGIP_MAX_CPU_GROUPS 256
+#else
+# define SUPGIP_MAX_CPU_GROUPS RTCPUSET_MAX_CPUS
+#endif
 
 /**
  * Global Information Page.
@@ -380,7 +426,8 @@ typedef struct SUPGLOBALINFOPAGE
     volatile uint16_t   cPresentCpus;
     /** The highest number of CPUs possible. */
     uint16_t            cPossibleCpus;
-    uint16_t            u16Padding0;
+    /** The highest number of CPU groups possible. */
+    uint16_t            cPossibleCpuGroups;
     /** The max CPU ID (RTMpGetMaxCpuId). */
     RTCPUID             idCpuMax;
     /** The applicability of SUPGIPCPU::i64TscDelta. */
@@ -398,6 +445,11 @@ typedef struct SUPGLOBALINFOPAGE
     uint16_t            aiCpuFromApicId[256];
     /** CPU set index to CPU table index. */
     uint16_t            aiCpuFromCpuSetIdx[RTCPUSET_MAX_CPUS];
+    /** Table indexed by CPU group to containing offsets to SUPGIPCPUGROUP
+     * structures, invalid entries are set to UINT16_MAX.  The offsets are relative
+     * to the start of this structure.
+     * @note Windows only. The other hosts sets all entries to UINT16_MAX! */
+    uint16_t            aoffCpuGroup[SUPGIP_MAX_CPU_GROUPS];
 
     /** Array of per-cpu data.
      * This is index by ApicId via the aiCpuFromApicId table.
@@ -414,6 +466,7 @@ AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs, 32);
 #else
 AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs, 256);
 #endif
+AssertCompile(sizeof(SUPGLOBALINFOPAGE) <= 0x1000); /* Keeping it less or equal to a page for raw-mode (saved state). */
 
 /** Pointer to the global info page.
  * @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
@@ -425,7 +478,7 @@ typedef SUPGLOBALINFOPAGE *PSUPGLOBALINFOPAGE;
 /** The GIP version.
  * Upper 16 bits is the major version. Major version is only changed with
  * incompatible changes in the GIP. */
-#define SUPGLOBALINFOPAGE_VERSION   0x00060001
+#define SUPGLOBALINFOPAGE_VERSION   0x00080000
 
 /**
  * SUPGLOBALINFOPAGE::u32Mode values.
@@ -571,6 +624,29 @@ DECLINLINE(uint64_t) SUPGetCpuHzFromGipBySetIndex(PSUPGLOBALINFOPAGE pGip, uint3
 }
 
 
+/**
+ * Gets the pointer to the per CPU data for a CPU given by its set index.
+ *
+ * @returns Pointer to the corresponding per CPU structure, or NULL if invalid.
+ * @param   pGip        The GIP pointer.
+ * @param   iCpuSet     The CPU set index of the CPU which we want.
+ */
+DECLINLINE(PSUPGIPCPU) SUPGetGipCpuBySetIndex(PSUPGLOBALINFOPAGE pGip, uint32_t iCpuSet)
+{
+    if (RT_LIKELY(   pGip
+                  && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC))
+    {
+        if (RT_LIKELY(iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
+        {
+            uint16_t iCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
+            if (RT_LIKELY(iCpu < pGip->cCpus))
+                return &pGip->aCPUs[iCpu];
+        }
+    }
+    return NULL;
+}
+
+
 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
 
 /** @internal */
diff --git a/include/VBox/sup.mac b/include/VBox/sup.mac
index 2023a92..5266154 100644
--- a/include/VBox/sup.mac
+++ b/include/VBox/sup.mac
@@ -38,13 +38,16 @@ struc SUPGIPCPU
     .iTSCHistoryHead            resd 1
     .au32TSCHistory             resd 8
     .u32PrevUpdateIntervalNS    resd 1
-    .au32Reserved0              resd (5)
+    .u32Reserved                resd 1
     .u64TSCSample               resq 1
-    .au32Reserved1              resd (1)
+    .au32Reserved1              resd 3
     .enmState                   resd 1
     .idCpu                      resd 1
     .iCpuSet                    resw 1
+    .iCpuGroup                  resw 1
+    .iCpuGroupMember            resw 1
     .idApic                     resw 1
+    .iReservedForNumaNode       resd 1
 endstruc
 
 %define SUPGIPUSETSCDELTA_NOT_APPLICABLE        0
@@ -56,6 +59,7 @@ endstruc
 %define SUPGIPGETCPU_APIC_ID                        1
 %define SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS       2
 %define SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS   4
+%define SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL 8
 
 
 %define SUPGLOBALINFOPAGE_MAGIC 0x19590106
@@ -75,7 +79,7 @@ struc SUPGLOBALINFOPAGE
     .cOnlineCpus                resw 1
     .cPresentCpus               resw 1
     .cPossibleCpus              resw 1
-    .u16Padding0                resw 1
+    .cPossibleCpuGroups         resw 1
     .idCpuMax                   resd 1
     .enmUseTscDelta             resd 1
     .fGetGipCpu                 resd 1
@@ -83,6 +87,7 @@ struc SUPGLOBALINFOPAGE
     .au32Padding1               resd 24
     .aiCpuFromApicId            resw 256
     .aiCpuFromCpuSetIdx         resw 256
+    .aoffCpuGroup               resw 256
     .aCPUs                      resb SUPGIPCPU_size
 endstruc
 
diff --git a/include/iprt/err.h b/include/iprt/err.h
index 3d411ed..73ac9cf 100644
--- a/include/iprt/err.h
+++ b/include/iprt/err.h
@@ -950,6 +950,8 @@ RT_C_DECLS_END
 /** Process does not have the increase quota (IQ) privilege needed for
  * creating a process as a given user. IQ is also called 'Increase quotas'. */
 #define VERR_PROC_IQ_PRIV_NOT_HELD          (-22413)
+/** The system has too many CPUs. */
+#define VERR_MP_TOO_MANY_CPUS               (-22414)
 /** @} */
 
 
diff --git a/include/iprt/err.mac b/include/iprt/err.mac
index 413b751..a984b7b 100644
--- a/include/iprt/err.mac
+++ b/include/iprt/err.mac
@@ -134,6 +134,7 @@
 %define VERR_PROC_TCB_PRIV_NOT_HELD    (-22411)
 %define VERR_PROC_APT_PRIV_NOT_HELD    (-22412)
 %define VERR_PROC_IQ_PRIV_NOT_HELD    (-22413)
+%define VERR_MP_TOO_MANY_CPUS    (-22414)
 %define VERR_FILE_IO_ERROR    (-100)
 %define VERR_OPEN_FAILED    (-101)
 %define VERR_FILE_NOT_FOUND    (-102)
diff --git a/include/iprt/formats/pecoff.h b/include/iprt/formats/pecoff.h
index 26bb0dc..46d2f22 100644
--- a/include/iprt/formats/pecoff.h
+++ b/include/iprt/formats/pecoff.h
@@ -576,7 +576,7 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V1
     uint32_t  ProcessHeapFlags;
     uint32_t  ProcessAffinityMask;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint32_t  EditList;
     uint32_t  SecurityCookie;
 } IMAGE_LOAD_CONFIG_DIRECTORY32_V1;
@@ -601,7 +601,7 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V2
     uint32_t  ProcessHeapFlags;
     uint32_t  ProcessAffinityMask;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint32_t  EditList;
     uint32_t  SecurityCookie;
     uint32_t  SEHandlerTable;
@@ -628,13 +628,13 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V3
     uint32_t  ProcessHeapFlags;
     uint32_t  ProcessAffinityMask;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint32_t  EditList;
     uint32_t  SecurityCookie;
     uint32_t  SEHandlerTable;
     uint32_t  SEHandlerCount;
     uint32_t  GuardCFCCheckFunctionPointer;
-    uint32_t  Reserved2;
+    uint32_t  GuardCFDispatchFunctionPointer;
     uint32_t  GuardCFFunctionTable;
     uint32_t  GuardCFFunctionCount;
     uint32_t  GuardFlags;
@@ -661,13 +661,13 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V4
     uint32_t  ProcessHeapFlags;
     uint32_t  ProcessAffinityMask;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint32_t  EditList;
     uint32_t  SecurityCookie;
     uint32_t  SEHandlerTable;
     uint32_t  SEHandlerCount;
     uint32_t  GuardCFCCheckFunctionPointer;
-    uint32_t  Reserved2;
+    uint32_t  GuardCFDispatchFunctionPointer;
     uint32_t  GuardCFFunctionTable;
     uint32_t  GuardCFFunctionCount;
     uint32_t  GuardFlags;
@@ -695,13 +695,13 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V5
     uint32_t  ProcessHeapFlags;
     uint32_t  ProcessAffinityMask;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint32_t  EditList;
     uint32_t  SecurityCookie;
     uint32_t  SEHandlerTable;
     uint32_t  SEHandlerCount;
     uint32_t  GuardCFCCheckFunctionPointer;
-    uint32_t  Reserved2;
+    uint32_t  GuardCFDispatchFunctionPointer;
     uint32_t  GuardCFFunctionTable;
     uint32_t  GuardCFFunctionCount;
     uint32_t  GuardFlags;
@@ -715,9 +715,92 @@ AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V5, 0x78);
 typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V5;
 typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V5;
 
-typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5   IMAGE_LOAD_CONFIG_DIRECTORY32;
-typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V5  PIMAGE_LOAD_CONFIG_DIRECTORY32;
-typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V5 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
+/** @since  Windows 10 build 14383 (or maybe earlier). */
+typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V6
+{
+    uint32_t  Size;                                 /**< 0x00 */
+    uint32_t  TimeDateStamp;                        /**< 0x04 */
+    uint16_t  MajorVersion;                         /**< 0x08 */
+    uint16_t  MinorVersion;                         /**< 0x0a */
+    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
+    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
+    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
+    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
+    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
+    uint32_t  LockPrefixTable;                      /**< 0x20 */
+    uint32_t  MaximumAllocationSize;                /**< 0x24 */
+    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
+    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
+    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
+    uint16_t  CSDVersion;                           /**< 0x34 */
+    uint16_t  DependentLoadFlags;                   /**< 0x36 */
+    uint32_t  EditList;                             /**< 0x38 */
+    uint32_t  SecurityCookie;                       /**< 0x3c */
+    uint32_t  SEHandlerTable;                       /**< 0x40 */
+    uint32_t  SEHandlerCount;                       /**< 0x44 */
+    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
+    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
+    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
+    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
+    uint32_t  GuardFlags;                           /**< 0x58 */
+    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
+    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
+    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
+    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
+    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
+    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
+    uint32_t  HybridMetadataPointer;                /**< 0x7c */
+} IMAGE_LOAD_CONFIG_DIRECTORY32_V6;
+AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V6, 0x80);
+typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V6 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V6;
+typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V6 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V6;
+
+/** @since  Windows 10 build 14901 (or maybe earlier). */
+typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V7
+{
+    uint32_t  Size;                                 /**< 0x00 */
+    uint32_t  TimeDateStamp;                        /**< 0x04 */
+    uint16_t  MajorVersion;                         /**< 0x08 */
+    uint16_t  MinorVersion;                         /**< 0x0a */
+    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
+    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
+    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
+    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
+    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
+    uint32_t  LockPrefixTable;                      /**< 0x20 */
+    uint32_t  MaximumAllocationSize;                /**< 0x24 */
+    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
+    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
+    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
+    uint16_t  CSDVersion;                           /**< 0x34 */
+    uint16_t  DependentLoadFlags;                   /**< 0x36 */
+    uint32_t  EditList;                             /**< 0x38 */
+    uint32_t  SecurityCookie;                       /**< 0x3c */
+    uint32_t  SEHandlerTable;                       /**< 0x40 */
+    uint32_t  SEHandlerCount;                       /**< 0x44 */
+    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
+    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
+    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
+    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
+    uint32_t  GuardFlags;                           /**< 0x58 */
+    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
+    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
+    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
+    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
+    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
+    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
+    uint32_t  HybridMetadataPointer;                /**< 0x7c */
+    uint32_t  FailFastIndirectProc;                 /**< 0x80 - temporary name, rename when we get symbols */
+    uint32_t  FailFastPointer;                      /**< 0x84 - temporary name, rename when we get symbols */
+    uint32_t  UnknownZero1;                         /**< 0x88 - temporary name, rename when we get symbols */
+} IMAGE_LOAD_CONFIG_DIRECTORY32_V7;
+AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V7, 0x8c);
+typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
+typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
+
+typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7   IMAGE_LOAD_CONFIG_DIRECTORY32;
+typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V7  PIMAGE_LOAD_CONFIG_DIRECTORY32;
+typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V7 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
 
 
 /* No _IMAGE_LOAD_CONFIG_DIRECTORY64_V1 exists. */
@@ -739,7 +822,7 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V2
     uint64_t  ProcessAffinityMask;
     uint32_t  ProcessHeapFlags;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint64_t  EditList;
     uint64_t  SecurityCookie;
     uint64_t  SEHandlerTable;
@@ -767,13 +850,13 @@ typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V3
     uint64_t  ProcessAffinityMask;
     uint32_t  ProcessHeapFlags;
     uint16_t  CSDVersion;
-    uint16_t  Reserved1;
+    uint16_t  DependentLoadFlags;
     uint64_t  EditList;
     uint64_t  SecurityCookie;
     uint64_t  SEHandlerTable;
     uint64_t  SEHandlerCount;
     uint64_t  GuardCFCCheckFunctionPointer;
-    uint64_t  Reserved2;
+    uint64_t  GuardCFDispatchFunctionPointer;
     uint64_t  GuardCFFunctionTable;
     uint64_t  GuardCFFunctionCount;
     uint32_t  GuardFlags;
@@ -786,32 +869,32 @@ typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_
 /** @since  Windows 10 (Preview (9879). */
 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V4
 {
-    uint32_t  Size;
-    uint32_t  TimeDateStamp;
-    uint16_t  MajorVersion;
-    uint16_t  MinorVersion;
-    uint32_t  GlobalFlagsClear;
-    uint32_t  GlobalFlagsSet;
-    uint32_t  CriticalSectionDefaultTimeout;
-    uint64_t  DeCommitFreeBlockThreshold;
-    uint64_t  DeCommitTotalFreeThreshold;
-    uint64_t  LockPrefixTable;
-    uint64_t  MaximumAllocationSize;
-    uint64_t  VirtualMemoryThreshold;
-    uint64_t  ProcessAffinityMask;
-    uint32_t  ProcessHeapFlags;
-    uint16_t  CSDVersion;
-    uint16_t  Reserved1;
-    uint64_t  EditList;
-    uint64_t  SecurityCookie;
-    uint64_t  SEHandlerTable;
-    uint64_t  SEHandlerCount;
-    uint64_t  GuardCFCCheckFunctionPointer;
-    uint64_t  Reserved2;
-    uint64_t  GuardCFFunctionTable;
-    uint64_t  GuardCFFunctionCount;
-    uint32_t  GuardFlags;
-    IMAGE_LOAD_CONFIG_CODE_INTEGRITY  CodeIntegrity;
+    uint32_t  Size;                                 /**< 0x00 */
+    uint32_t  TimeDateStamp;                        /**< 0x04 */
+    uint16_t  MajorVersion;                         /**< 0x08 */
+    uint16_t  MinorVersion;                         /**< 0x0a */
+    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
+    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
+    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
+    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
+    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
+    uint64_t  LockPrefixTable;                      /**< 0x28 */
+    uint64_t  MaximumAllocationSize;                /**< 0x30 */
+    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
+    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
+    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
+    uint16_t  CSDVersion;                           /**< 0x4c */
+    uint16_t  DependentLoadFlags;                   /**< 0x4e */
+    uint64_t  EditList;                             /**< 0x50 */
+    uint64_t  SecurityCookie;                       /**< 0x58 */
+    uint64_t  SEHandlerTable;                       /**< 0x60 */
+    uint64_t  SEHandlerCount;                       /**< 0x68 */
+    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
+    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
+    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
+    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
+    uint32_t  GuardFlags;                           /**< 0x90 */
+    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
 } IMAGE_LOAD_CONFIG_DIRECTORY64_V4;
 AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V4, 0xa0);
 typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V4;
@@ -820,44 +903,127 @@ typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_
 /** @since  Windows 10 build 14286 (or maybe earlier). */
 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V5
 {
-    uint32_t  Size;
-    uint32_t  TimeDateStamp;
-    uint16_t  MajorVersion;
-    uint16_t  MinorVersion;
-    uint32_t  GlobalFlagsClear;
-    uint32_t  GlobalFlagsSet;
-    uint32_t  CriticalSectionDefaultTimeout;
-    uint64_t  DeCommitFreeBlockThreshold;
-    uint64_t  DeCommitTotalFreeThreshold;
-    uint64_t  LockPrefixTable;
-    uint64_t  MaximumAllocationSize;
-    uint64_t  VirtualMemoryThreshold;
-    uint64_t  ProcessAffinityMask;
-    uint32_t  ProcessHeapFlags;
-    uint16_t  CSDVersion;
-    uint16_t  Reserved1;
-    uint64_t  EditList;
-    uint64_t  SecurityCookie;
-    uint64_t  SEHandlerTable;
-    uint64_t  SEHandlerCount;
-    uint64_t  GuardCFCCheckFunctionPointer;
-    uint64_t  Reserved2;
-    uint64_t  GuardCFFunctionTable;
-    uint64_t  GuardCFFunctionCount;
-    uint32_t  GuardFlags;
-    IMAGE_LOAD_CONFIG_CODE_INTEGRITY  CodeIntegrity;
-    uint64_t  GuardAddressTakenIatEntryTable;
-    uint64_t  GuardAddressTakenIatEntryCount;
-    uint64_t  GuardLongJumpTargetTable;
-    uint64_t  GuardLongJumpTargetCount;
+    uint32_t  Size;                                 /**< 0x00 */
+    uint32_t  TimeDateStamp;                        /**< 0x04 */
+    uint16_t  MajorVersion;                         /**< 0x08 */
+    uint16_t  MinorVersion;                         /**< 0x0a */
+    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
+    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
+    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
+    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
+    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
+    uint64_t  LockPrefixTable;                      /**< 0x28 */
+    uint64_t  MaximumAllocationSize;                /**< 0x30 */
+    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
+    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
+    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
+    uint16_t  CSDVersion;                           /**< 0x4c */
+    uint16_t  DependentLoadFlags;                   /**< 0x4e */
+    uint64_t  EditList;                             /**< 0x50 */
+    uint64_t  SecurityCookie;                       /**< 0x58 */
+    uint64_t  SEHandlerTable;                       /**< 0x60 */
+    uint64_t  SEHandlerCount;                       /**< 0x68 */
+    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
+    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
+    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
+    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
+    uint32_t  GuardFlags;                           /**< 0x90 */
+    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
+    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
+    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
+    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
+    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
 } IMAGE_LOAD_CONFIG_DIRECTORY64_V5;
 AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V5, 0xc0);
 typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V5;
 typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V5;
 
-typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5   IMAGE_LOAD_CONFIG_DIRECTORY64;
-typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V5  PIMAGE_LOAD_CONFIG_DIRECTORY64;
-typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V5 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
+/** @since  Windows 10 build 14393 (or maybe earlier). */
+typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V6
+{
+    uint32_t  Size;                                 /**< 0x00 */
+    uint32_t  TimeDateStamp;                        /**< 0x04 */
+    uint16_t  MajorVersion;                         /**< 0x08 */
+    uint16_t  MinorVersion;                         /**< 0x0a */
+    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
+    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
+    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
+    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
+    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
+    uint64_t  LockPrefixTable;                      /**< 0x28 */
+    uint64_t  MaximumAllocationSize;                /**< 0x30 */
+    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
+    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
+    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
+    uint16_t  CSDVersion;                           /**< 0x4c */
+    uint16_t  DependentLoadFlags;                   /**< 0x4e */
+    uint64_t  EditList;                             /**< 0x50 */
+    uint64_t  SecurityCookie;                       /**< 0x58 */
+    uint64_t  SEHandlerTable;                       /**< 0x60 */
+    uint64_t  SEHandlerCount;                       /**< 0x68 */
+    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
+    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
+    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
+    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
+    uint32_t  GuardFlags;                           /**< 0x90 */
+    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
+    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
+    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
+    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
+    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
+    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
+    uint64_t  HybridMetadataPointer;                /**< 0xc8 */
+} IMAGE_LOAD_CONFIG_DIRECTORY64_V6;
+AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V6, 0xd0);
+typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V6 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V6;
+typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V6 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V6;
+
+/** @since  Windows 10 build 14901 (or maybe earlier). */
+typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V7
+{
+    uint32_t  Size;                                 /**< 0x00 */
+    uint32_t  TimeDateStamp;                        /**< 0x04 */
+    uint16_t  MajorVersion;                         /**< 0x08 */
+    uint16_t  MinorVersion;                         /**< 0x0a */
+    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
+    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
+    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
+    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
+    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
+    uint64_t  LockPrefixTable;                      /**< 0x28 */
+    uint64_t  MaximumAllocationSize;                /**< 0x30 */
+    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
+    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
+    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
+    uint16_t  CSDVersion;                           /**< 0x4c */
+    uint16_t  DependentLoadFlags;                   /**< 0x4e */
+    uint64_t  EditList;                             /**< 0x50 */
+    uint64_t  SecurityCookie;                       /**< 0x58 */
+    uint64_t  SEHandlerTable;                       /**< 0x60 */
+    uint64_t  SEHandlerCount;                       /**< 0x68 */
+    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
+    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
+    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
+    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
+    uint32_t  GuardFlags;                           /**< 0x90 */
+    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
+    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
+    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
+    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
+    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
+    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
+    uint64_t  HybridMetadataPointer;                /**< 0xc8 */
+    uint64_t  FailFastIndirectProc;                 /**< 0xd0 - temporary name, rename when we get symbols */
+    uint64_t  FailFastPointer;                      /**< 0xd8 - temporary name, rename when we get symbols */
+    uint64_t  UnknownZero1;                         /**< 0xe0 - temporary name, rename when we get symbols */
+} IMAGE_LOAD_CONFIG_DIRECTORY64_V7;
+AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V7, 0xe8);
+typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V7;
+typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V7;
+
+typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7   IMAGE_LOAD_CONFIG_DIRECTORY64;
+typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V7  PIMAGE_LOAD_CONFIG_DIRECTORY64;
+typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V7 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
 
 /** @} */
 
diff --git a/include/iprt/mangling.h b/include/iprt/mangling.h
index c28bcf6..5dfbac1 100644
--- a/include/iprt/mangling.h
+++ b/include/iprt/mangling.h
@@ -1302,6 +1302,8 @@
 # define RTMpGetCount                                   RT_MANGLER(RTMpGetCount)
 # define RTMpGetCurFrequency                            RT_MANGLER(RTMpGetCurFrequency)
 # define RTMpGetDescription                             RT_MANGLER(RTMpGetDescription)
+# define RTMpGetCpuGroupCounts                          RT_MANGLER(RTMpGetCpuGroupCounts)
+# define RTMpGetMaxCpuGroupCount                        RT_MANGLER(RTMpGetMaxCpuGroupCount)
 # define RTMpGetMaxCpuId                                RT_MANGLER(RTMpGetMaxCpuId)
 # define RTMpGetMaxFrequency                            RT_MANGLER(RTMpGetMaxFrequency)
 # define RTMpGetOnlineCount                             RT_MANGLER(RTMpGetOnlineCount)
@@ -1325,6 +1327,7 @@
 # define RTMpOnPairIsConcurrentExecSupported            RT_MANGLER(RTMpOnPairIsConcurrentExecSupported) /* r0drv */
 # define RTMpOnSpecific                                 RT_MANGLER(RTMpOnSpecific)             /* r0drv */
 # define RTMpPokeCpu                                    RT_MANGLER(RTMpPokeCpu)                /* r0drv */
+# define RTMpSetIndexFromCpuGroupMember                 RT_MANGLER(RTMpSetIndexFromCpuGroupMember)
 # define RTMsgError                                     RT_MANGLER(RTMsgError)
 # define RTMsgErrorExit                                 RT_MANGLER(RTMsgErrorExit)
 # define RTMsgErrorExitV                                RT_MANGLER(RTMsgErrorExitV)
@@ -2103,6 +2106,8 @@
 # define RTTimeNanoTSLegacyAsyncUseApicId_EndProc               RT_MANGLER(RTTimeNanoTSLegacyAsyncUseApicId_EndProc)
 # define RTTimeNanoTSLegacyAsyncUseRdtscp                       RT_MANGLER(RTTimeNanoTSLegacyAsyncUseRdtscp)
 # define RTTimeNanoTSLegacyAsyncUseRdtscp_EndProc               RT_MANGLER(RTTimeNanoTSLegacyAsyncUseRdtscp_EndProc)
+# define RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl           RT_MANGLER(RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl)
+# define RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl_EndProc   RT_MANGLER(RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl_EndProc)
 # define RTTimeNanoTSLegacyAsyncUseIdtrLim                      RT_MANGLER(RTTimeNanoTSLegacyAsyncUseIdtrLim)
 # define RTTimeNanoTSLegacyAsyncUseIdtrLim_EndProc              RT_MANGLER(RTTimeNanoTSLegacyAsyncUseIdtrLim_EndProc)
 # define RTTimeNanoTSLegacySyncInvarNoDelta                     RT_MANGLER(RTTimeNanoTSLegacySyncInvarNoDelta)
@@ -2121,6 +2126,8 @@
 # define RTTimeNanoTSLFenceAsyncUseApicId_EndProc               RT_MANGLER(RTTimeNanoTSLFenceAsyncUseApicId_EndProc)
 # define RTTimeNanoTSLFenceAsyncUseRdtscp                       RT_MANGLER(RTTimeNanoTSLFenceAsyncUseRdtscp)
 # define RTTimeNanoTSLFenceAsyncUseRdtscp_EndProc               RT_MANGLER(RTTimeNanoTSLFenceAsyncUseRdtscp_EndProc)
+# define RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl           RT_MANGLER(RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl)
+# define RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl_EndProc   RT_MANGLER(RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl_EndProc)
 # define RTTimeNanoTSLFenceAsyncUseIdtrLim                      RT_MANGLER(RTTimeNanoTSLFenceAsyncUseIdtrLim)
 # define RTTimeNanoTSLFenceAsyncUseIdtrLim_EndProc              RT_MANGLER(RTTimeNanoTSLFenceAsyncUseIdtrLim_EndProc)
 # define RTTimeNanoTSLFenceSyncInvarNoDelta                     RT_MANGLER(RTTimeNanoTSLFenceSyncInvarNoDelta)
diff --git a/include/iprt/mp.h b/include/iprt/mp.h
index b537ffe..ad7d3e2 100644
--- a/include/iprt/mp.h
+++ b/include/iprt/mp.h
@@ -89,6 +89,37 @@ RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu);
 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu);
 
 /**
+ * Translates an NT process group member to a CPU set index.
+ *
+ * @returns CPU set index, -1 if not valid.
+ * @param   idxGroup        The CPU group.
+ * @param   idxMember       The CPU group member number.
+ *
+ * @remarks Only available on Windows.
+ */
+RTDECL(int) RTMpSetIndexFromCpuGroupMember(uint32_t idxGroup, uint32_t idxMember);
+
+/**
+ * Gets the member numbers for a CPU group.
+ *
+ * @returns Maximum number of group members.
+ * @param   idxGroup        The CPU group.
+ * @param   pcActive        Where to return the number of active members.
+ *
+ * @remarks Only available on Windows.
+ */
+RTDECL(uint32_t) RTMpGetCpuGroupCounts(uint32_t idxGroup, uint32_t *pcActive);
+
+/**
+ * Get the maximum number of CPU groups.
+ *
+ * @returns Maximum number of CPU groups.
+ *
+ * @remarks Only available on Windows.
+ */
+RTDECL(uint32_t) RTMpGetMaxCpuGroupCount(void);
+
+/**
  * Gets the max CPU identifier (inclusive).
  *
  * Intended for brute force enumerations, but use with
diff --git a/include/iprt/nt/nt.h b/include/iprt/nt/nt.h
index 589573e..e16cedc 100644
--- a/include/iprt/nt/nt.h
+++ b/include/iprt/nt/nt.h
@@ -182,6 +182,12 @@
 /*
  * Use ntifs.h and wdm.h.
  */
+# if _MSC_VER >= 1200 /* Fix/workaround for KeInitializeSpinLock visibility issue on AMD64. */
+#  define FORCEINLINE static __forceinline
+# else
+#  define FORCEINLINE static __inline
+# endif
+
 # pragma warning(push)
 # ifdef RT_ARCH_X86
 #  define _InterlockedAddLargeStatistic  _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
@@ -2372,6 +2378,17 @@ typedef RTL_CRITICAL_SECTION *PRTL_CRITICAL_SECTION;
 
 /*NTSYSAPI ULONG NTAPI RtlNtStatusToDosError(NTSTATUS rcNt);*/
 
+/** @def RTL_QUERY_REGISTRY_TYPECHECK
+ * WDK 8.1+, backported in updates, ignored in older. */
+#if !defined(RTL_QUERY_REGISTRY_TYPECHECK) || defined(DOXYGEN_RUNNING)
+# define RTL_QUERY_REGISTRY_TYPECHECK       UINT32_C(0x00000100)
+#endif
+/** @def RTL_QUERY_REGISTRY_TYPECHECK_SHIFT
+ * WDK 8.1+, backported in updates, ignored in older. */
+#if !defined(RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) || defined(DOXYGEN_RUNNING)
+# define RTL_QUERY_REGISTRY_TYPECHECK_SHIFT 24
+#endif
+
 
 RT_C_DECLS_END
 /** @} */
@@ -2419,6 +2436,20 @@ NTSYSAPI KEPROCESSORINDEX  NTAPI KeFindFirstSetLeftAffinityEx(PCKAFFINITY_EX pAf
 typedef  KEPROCESSORINDEX (NTAPI *PFNKEFINDFIRSTSETLEFTAFFINITYEX)(PCKAFFINITY_EX pAffinity);
 typedef  NTSTATUS (NTAPI *PFNKEGETPROCESSORNUMBERFROMINDEX)(KEPROCESSORINDEX idxProcessor, PPROCESSOR_NUMBER pProcNumber);
 typedef  KEPROCESSORINDEX (NTAPI *PFNKEGETPROCESSORINDEXFROMNUMBER)(const PROCESSOR_NUMBER *pProcNumber);
+typedef  NTSTATUS (NTAPI *PFNKEGETPROCESSORNUMBERFROMINDEX)(KEPROCESSORINDEX ProcIndex, PROCESSOR_NUMBER *pProcNumber);
+typedef  KEPROCESSORINDEX (NTAPI *PFNKEGETCURRENTPROCESSORNUMBEREX)(const PROCESSOR_NUMBER *pProcNumber);
+typedef  KAFFINITY (NTAPI *PFNKEQUERYACTIVEPROCESSORS)(VOID);
+typedef  ULONG   (NTAPI *PFNKEQUERYMAXIMUMPROCESSORCOUNT)(VOID);
+typedef  ULONG   (NTAPI *PFNKEQUERYMAXIMUMPROCESSORCOUNTEX)(USHORT GroupNumber);
+typedef  USHORT  (NTAPI *PFNKEQUERYMAXIMUMGROUPCOUNT)(VOID);
+typedef  ULONG   (NTAPI *PFNKEQUERYACTIVEPROCESSORCOUNT)(KAFFINITY *pfActiveProcessors);
+typedef  ULONG   (NTAPI *PFNKEQUERYACTIVEPROCESSORCOUNTEX)(USHORT GroupNumber);
+typedef  NTSTATUS (NTAPI *PFNKEQUERYLOGICALPROCESSORRELATIONSHIP)(PROCESSOR_NUMBER *pProcNumber,
+                                                                  LOGICAL_PROCESSOR_RELATIONSHIP RelationShipType,
+                                                                  SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pInfo, PULONG pcbInfo);
+typedef  PVOID   (NTAPI *PFNKEREGISTERPROCESSORCHANGECALLBACK)(PPROCESSOR_CALLBACK_FUNCTION pfnCallback, void *pvUser, ULONG fFlags);
+typedef  VOID    (NTAPI *PFNKEDEREGISTERPROCESSORCHANGECALLBACK)(PVOID pvCallback);
+typedef  NTSTATUS (NTAPI *PFNKESETTARGETPROCESSORDPCEX)(KDPC *pDpc, PROCESSOR_NUMBER *pProcNumber);
 
 NTSYSAPI BOOLEAN  NTAPI ObFindHandleForObject(PEPROCESS pProcess, PVOID pvObject, POBJECT_TYPE pObjectType,
                                               PVOID pvOptionalConditions, PHANDLE phFound);
diff --git a/include/iprt/time.h b/include/iprt/time.h
index 5ca5331..a3dcd0d 100644
--- a/include/iprt/time.h
+++ b/include/iprt/time.h
@@ -953,12 +953,14 @@ RTDECL(uint64_t) RTTimeNanoTSLFenceSyncInvarNoDelta(PRTTIMENANOTSDATA pData);
 #ifdef IN_RING3
 RTDECL(uint64_t) RTTimeNanoTSLegacyAsyncUseApicId(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLegacyAsyncUseRdtscp(PRTTIMENANOTSDATA pData);
+RTDECL(uint64_t) RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLegacyAsyncUseIdtrLim(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLegacySyncInvarWithDeltaUseApicId(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLegacySyncInvarWithDeltaUseRdtscp(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLegacySyncInvarWithDeltaUseIdtrLim(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLFenceAsyncUseApicId(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLFenceAsyncUseRdtscp(PRTTIMENANOTSDATA pData);
+RTDECL(uint64_t) RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLFenceAsyncUseIdtrLim(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicId(PRTTIMENANOTSDATA pData);
 RTDECL(uint64_t) RTTimeNanoTSLFenceSyncInvarWithDeltaUseRdtscp(PRTTIMENANOTSDATA pData);
diff --git a/include/iprt/x86.mac b/include/iprt/x86.mac
index a97f613..6b98030 100644
--- a/include/iprt/x86.mac
+++ b/include/iprt/x86.mac
@@ -492,6 +492,7 @@
 %define  MSR_K6_EFER_LME                     RT_BIT_32(8)
 %define  MSR_K6_EFER_LMA                     RT_BIT_32(10)
 %define  MSR_K6_EFER_NXE                     RT_BIT_32(11)
+%define  MSR_K6_EFER_BIT_NXE                 11
 %define  MSR_K6_EFER_SVME                    RT_BIT_32(12)
 %define  MSR_K6_EFER_LMSLE                   RT_BIT_32(13)
 %define  MSR_K6_EFER_FFXSR                   RT_BIT_32(14)
@@ -570,6 +571,7 @@
 %define X86_PTE_BIT_D                       6
 %define X86_PTE_BIT_PAT                     7
 %define X86_PTE_BIT_G                       8
+%define X86_PTE_PAE_BIT_NX                  63
 %define X86_PTE_P                           RT_BIT_32(0)
 %define X86_PTE_RW                          RT_BIT_32(1)
 %define X86_PTE_US                          RT_BIT_32(2)
diff --git a/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp b/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
index fee3729..5ecfb01 100644
--- a/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
+++ b/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
@@ -1463,6 +1463,8 @@ static void vgdrvWaitFreeUnlocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait
  *
  * All entries in the wake-up list gets signalled and moved to the woken-up
  * list.
+ * At least on Windows this function can be invoked concurrently from
+ * different VCPUs. So, be thread-safe.
  *
  * @param   pDevExt         The device extension.
  */
@@ -1477,6 +1479,9 @@ void VGDrvCommonWaitDoWakeUps(PVBOXGUESTDEVEXT pDevExt)
             PVBOXGUESTWAIT pWait = RTListGetFirst(&pDevExt->WakeUpList, VBOXGUESTWAIT, ListNode);
             if (!pWait)
                 break;
+            /* Prevent other threads from accessing pWait when spinlock is released. */
+            RTListNodeRemove(&pWait->ListNode);
+
             pWait->fPendingWakeUp = true;
             RTSpinlockRelease(pDevExt->EventSpinlock);
 
@@ -1484,12 +1489,11 @@ void VGDrvCommonWaitDoWakeUps(PVBOXGUESTDEVEXT pDevExt)
             AssertRC(rc);
 
             RTSpinlockAcquire(pDevExt->EventSpinlock);
+            Assert(pWait->ListNode.pNext == NULL && pWait->ListNode.pPrev == NULL);
+            RTListAppend(&pDevExt->WokenUpList, &pWait->ListNode);
             pWait->fPendingWakeUp = false;
-            if (!pWait->fFreeMe)
-            {
-                RTListNodeRemove(&pWait->ListNode);
-                RTListAppend(&pDevExt->WokenUpList, &pWait->ListNode);
-            }
+            if (RT_LIKELY(!pWait->fFreeMe))
+            { /* likely */ }
             else
             {
                 pWait->fFreeMe = false;
diff --git a/src/VBox/Additions/common/crOpenGL/DD_glc.py b/src/VBox/Additions/common/crOpenGL/DD_glc.py
old mode 100644
new mode 100755
index ac465b3..db5c321
--- a/src/VBox/Additions/common/crOpenGL/DD_glc.py
+++ b/src/VBox/Additions/common/crOpenGL/DD_glc.py
@@ -1,4 +1,5 @@
-print """
+from __future__ import print_function
+print("""
 /** @file
  * VBox OpenGL chromium functions header
  */
@@ -14,7 +15,7 @@ print """
  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  */
-"""
+""")
 # Copyright (c) 2001, Stanford University
 # All rights reserved.
 #
@@ -26,7 +27,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE DD_gl.py SCRIPT */
 
 #include "chromium.h"
@@ -35,7 +36,7 @@ print """
 #include "stub.h"
 #include "dri_drv.h"
 #include "cr_gl.h"
-"""
+""")
 
 commoncall_special = [
    "ArrayElement",
@@ -121,18 +122,18 @@ for func_name in keys:
     params = apiutil.Parameters(func_name)
 
     if func_name in commoncall_special:
-        print "%s vboxDD_gl%s( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params) )
+        print("%s vboxDD_gl%s(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params) ))
     else:
         if apiutil.MakeDeclarationString(params)=="void":
-            print "%s vboxDD_gl%s( GLcontext *ctx )" % (return_type, func_name )
+            print("%s vboxDD_gl%s(GLcontext *ctx)" % (return_type, func_name ))
         else:
-            print "%s vboxDD_gl%s( GLcontext *ctx, %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params) )
-    print "{"
+            print("%s vboxDD_gl%s(GLcontext *ctx, %s)" % (return_type, func_name, apiutil.MakeDeclarationString(params) ))
+    print("{")
 
     if return_type != "void":
-        print "\treturn ",
+        print("\treturn ", end=' ')
 
-    print "\tcr_gl%s( %s );" % (func_name, apiutil.MakeCallString(params))
-    print "}"
-    print ""
+    print("\tcr_gl%s(%s);" % (func_name, apiutil.MakeCallString(params)))
+    print("}")
+    print("")
 
diff --git a/src/VBox/Additions/common/crOpenGL/DD_glh.py b/src/VBox/Additions/common/crOpenGL/DD_glh.py
old mode 100644
new mode 100755
index 0e3de42..73eb550
--- a/src/VBox/Additions/common/crOpenGL/DD_glh.py
+++ b/src/VBox/Additions/common/crOpenGL/DD_glh.py
@@ -1,4 +1,5 @@
-print """
+from __future__ import print_function
+print("""
 /** @file
  * VBox OpenGL chromium functions header
  */
@@ -14,7 +15,7 @@ print """
  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  */
-"""
+""")
 # Copyright (c) 2001, Stanford University
 # All rights reserved.
 #
@@ -26,7 +27,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE DD_gl.py SCRIPT */
 #ifndef __DD_GL_H__
 #define __DD_GL_H__
@@ -36,7 +37,7 @@ print """
 #include "cr_version.h"
 #include "stub.h"
 
-"""
+""")
 
 commoncall_special = [
    "ArrayElement",
@@ -123,13 +124,13 @@ for func_name in keys:
     params = apiutil.Parameters(func_name)
 
     if func_name in commoncall_special:
-        print "extern %s vboxDD_gl%s( %s );" % (return_type, func_name,
-                                                apiutil.MakeDeclarationString( params ))
+        print("extern %s vboxDD_gl%s(%s);" % (return_type, func_name,
+                                                apiutil.MakeDeclarationString( params )))
     else:
         if apiutil.MakeDeclarationString(params)=="void":
-            print "extern %s vboxDD_gl%s( GLcontext *ctx );" % (return_type, func_name)
+            print("extern %s vboxDD_gl%s(GLcontext *ctx);" % (return_type, func_name))
         else:
-            print "extern %s vboxDD_gl%s( GLcontext *ctx, %s );" % (return_type, func_name,
-                                                                    apiutil.MakeDeclarationString( params ))
+            print("extern %s vboxDD_gl%s(GLcontext *ctx, %s);" % (return_type, func_name,
+                                                                    apiutil.MakeDeclarationString( params )))
 
-print "#endif /* __DD_GL_H__ */"
+print("#endif /* __DD_GL_H__ */")
diff --git a/src/VBox/Additions/common/crOpenGL/Linux_i386_exports.py b/src/VBox/Additions/common/crOpenGL/Linux_i386_exports.py
old mode 100644
new mode 100755
index cad500a..653b00a
--- a/src/VBox/Additions/common/crOpenGL/Linux_i386_exports.py
+++ b/src/VBox/Additions/common/crOpenGL/Linux_i386_exports.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -16,14 +17,14 @@ def GenerateEntrypoints():
     # Get sorted list of dispatched functions.
     # The order is very important - it must match cr_opcodes.h
     # and spu_dispatch_table.h
-    print '%include "iprt/asmdefs.mac"'
-    print ""
-    print "%ifdef RT_ARCH_AMD64"
-    print "extern glim"
-    print "%else ; X86"
-    print "extern glim"
-    print "%endif"
-    print ""
+    print('%include "iprt/asmdefs.mac"')
+    print("")
+    print("%ifdef RT_ARCH_AMD64")
+    print("extern glim")
+    print("%else ; X86")
+    print("extern glim")
+    print("%endif")
+    print("")
 
     keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -34,21 +35,21 @@ def GenerateEntrypoints():
         if apiutil.Category(func_name) == "VBox":
             continue
 
-        print "BEGINPROC_EXPORTED gl%s" % func_name
-        print "%ifdef RT_ARCH_AMD64"
-        print "\tmov \trax, qword glim+%d" % (8*index)
-        print "\tjmp \t[rax]"
-        print "%else ; X86"
-        print "\tmov \teax, dword glim+%d" % (4*index)
-        print "\tjmp \t[eax]"
-        print "%endif"
-        print "ENDPROC gl%s" % func_name
-        print ""
+        print("BEGINPROC_EXPORTED gl%s" % func_name)
+        print("%ifdef RT_ARCH_AMD64")
+        print("\tmov \trax, qword glim+%d" % (8*index))
+        print("\tjmp \t[rax]")
+        print("%else ; X86")
+        print("\tmov \teax, dword glim+%d" % (4*index))
+        print("\tjmp \t[eax]")
+        print("%endif")
+        print("ENDPROC gl%s" % func_name)
+        print("")
 
 
-    print ';'
-    print '; Aliases'
-    print ';'
+    print(';')
+    print('; Aliases')
+    print(';')
 
     # Now loop over all the functions and take care of any aliases
     allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -65,30 +66,30 @@ def GenerateEntrypoints():
         if alias:
             # this dict lookup should never fail (raise an exception)!
             index = keys.index(alias)
-            print "BEGINPROC_EXPORTED gl%s" % func_name
-            print "%ifdef RT_ARCH_AMD64"
-            print "\tmov \trax, qword glim+%d" % (8*index)
-            print "\tjmp \t[rax]"
-            print "%else ; X86"
-            print "\tmov \teax, dword glim+%d" % (4*index)
-            print "\tjmp \t[eax]"
-            print "%endif"
-            print "ENDPROC gl%s" % func_name
-            print ""
-
-
-    print ';'
-    print '; No-op stubs'
-    print ';'
+            print("BEGINPROC_EXPORTED gl%s" % func_name)
+            print("%ifdef RT_ARCH_AMD64")
+            print("\tmov \trax, qword glim+%d" % (8*index))
+            print("\tjmp \t[rax]")
+            print("%else ; X86")
+            print("\tmov \teax, dword glim+%d" % (4*index))
+            print("\tjmp \t[eax]")
+            print("%endif")
+            print("ENDPROC gl%s" % func_name)
+            print("")
+
+
+    print(';')
+    print('; No-op stubs')
+    print(';')
 
     # Now generate no-op stub functions
     for func_name in allkeys:
         if "stub" in apiutil.ChromiumProps(func_name):
-            print "BEGINPROC_EXPORTED gl%s" % func_name
-            print "\tleave"
-            print "\tret"
-            print "ENDPROC gl%s" % func_name
-            print ""
+            print("BEGINPROC_EXPORTED gl%s" % func_name)
+            print("\tleave")
+            print("\tret")
+            print("ENDPROC gl%s" % func_name)
+            print("")
 
 
 GenerateEntrypoints()
diff --git a/src/VBox/Additions/common/crOpenGL/Linux_i386_exports_dri.py b/src/VBox/Additions/common/crOpenGL/Linux_i386_exports_dri.py
old mode 100644
new mode 100755
index 6abb8a1..e212fb6
--- a/src/VBox/Additions/common/crOpenGL/Linux_i386_exports_dri.py
+++ b/src/VBox/Additions/common/crOpenGL/Linux_i386_exports_dri.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -16,14 +17,14 @@ def GenerateEntrypoints():
     # Get sorted list of dispatched functions.
     # The order is very important - it must match cr_opcodes.h
     # and spu_dispatch_table.h
-    print '%include "iprt/asmdefs.mac"'
-    print ""
-    print "%ifdef RT_ARCH_AMD64"
-    print "extern glim"
-    print "%else ; X86"
-    print "extern glim"
-    print "%endif"
-    print ""
+    print('%include "iprt/asmdefs.mac"')
+    print("")
+    print("%ifdef RT_ARCH_AMD64")
+    print("extern glim")
+    print("%else ; X86")
+    print("extern glim")
+    print("%endif")
+    print("")
 
     keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -34,21 +35,21 @@ def GenerateEntrypoints():
         if apiutil.Category(func_name) == "VBox":
             continue
 
-        print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-        print "%ifdef RT_ARCH_AMD64"
-        print "\tmov \trax, qword glim+%d" % (8*index)
-        print "\tjmp \t[rax]"
-        print "%else ; X86"
-        print "\tmov \teax, dword glim+%d" % (4*index)
-        print "\tjmp \t[eax]"
-        print "%endif"
-        print "ENDPROC cr_gl%s" % func_name
-        print ""
+        print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+        print("%ifdef RT_ARCH_AMD64")
+        print("\tmov \trax, qword glim+%d" % (8*index))
+        print("\tjmp \t[rax]")
+        print("%else ; X86")
+        print("\tmov \teax, dword glim+%d" % (4*index))
+        print("\tjmp \t[eax]")
+        print("%endif")
+        print("ENDPROC cr_gl%s" % func_name)
+        print("")
 
 
-    print ';'
-    print '; Aliases'
-    print ';'
+    print(';')
+    print('; Aliases')
+    print(';')
 
     # Now loop over all the functions and take care of any aliases
     allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -65,30 +66,30 @@ def GenerateEntrypoints():
         if alias:
             # this dict lookup should never fail (raise an exception)!
             index = keys.index(alias)
-            print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-            print "%ifdef RT_ARCH_AMD64"
-            print "\tmov \trax, qword glim+%d" % (8*index)
-            print "\tjmp \t[rax]"
-            print "%else ; X86"
-            print "\tmov \teax, dword glim+%d" % (4*index)
-            print "\tjmp \t[eax]"
-            print "%endif"
-            print "ENDPROC cr_gl%s" % func_name
-            print ""
-
-
-    print ';'
-    print '; No-op stubs'
-    print ';'
+            print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+            print("%ifdef RT_ARCH_AMD64")
+            print("\tmov \trax, qword glim+%d" % (8*index))
+            print("\tjmp \t[rax]")
+            print("%else ; X86")
+            print("\tmov \teax, dword glim+%d" % (4*index))
+            print("\tjmp \t[eax]")
+            print("%endif")
+            print("ENDPROC cr_gl%s" % func_name)
+            print("")
+
+
+    print(';')
+    print('; No-op stubs')
+    print(';')
 
     # Now generate no-op stub functions
     for func_name in allkeys:
         if "stub" in apiutil.ChromiumProps(func_name):
-            print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-            print "\tleave"
-            print "\tret"
-            print "ENDPROC cr_gl%s" % func_name
-            print ""
+            print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+            print("\tleave")
+            print("\tret")
+            print("ENDPROC cr_gl%s" % func_name)
+            print("")
 
 
 GenerateEntrypoints()
diff --git a/src/VBox/Additions/common/crOpenGL/Linux_i386_glxapi_exports.py b/src/VBox/Additions/common/crOpenGL/Linux_i386_glxapi_exports.py
index 30f14db..087861f 100755
--- a/src/VBox/Additions/common/crOpenGL/Linux_i386_glxapi_exports.py
+++ b/src/VBox/Additions/common/crOpenGL/Linux_i386_glxapi_exports.py
@@ -10,6 +10,7 @@ VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 """
 
+from __future__ import print_function
 import sys
 
 #Note, this should match the fakedri_glxfuncsList.h order
@@ -79,26 +80,26 @@ glx_functions = [
 "FreeContextEXT"
 ];
 
-print '%include "iprt/asmdefs.mac"'
-print ""
-print "%ifdef RT_ARCH_AMD64"
-print "extern glxim"
-print "%else ; X86"
-print "extern glxim"
-print "%endif"
-print ""
+print('%include "iprt/asmdefs.mac"')
+print("")
+print("%ifdef RT_ARCH_AMD64")
+print("extern glxim")
+print("%else ; X86")
+print("extern glxim")
+print("%endif")
+print("")
 
 for index in range(len(glx_functions)):
     func_name = glx_functions[index]
 
-    print "BEGINPROC_EXPORTED vbox_glX%s" % func_name
-    print "%ifdef RT_ARCH_AMD64"
-    print "\tmov \trax, qword glxim+%d" % (8*index)
-    print "\tjmp \t[rax]"
-    print "%else ; X86"
-    print "\tmov \teax, dword glxim+%d" % (4*index)
-    print "\tjmp \t[eax]"
-    print "%endif"
-    print "ENDPROC vbox_glX%s" % func_name
-    print ""
+    print("BEGINPROC_EXPORTED vbox_glX%s" % func_name)
+    print("%ifdef RT_ARCH_AMD64")
+    print("\tmov \trax, qword glxim+%d" % (8*index))
+    print("\tjmp \t[rax]")
+    print("%else ; X86")
+    print("\tmov \teax, dword glxim+%d" % (4*index))
+    print("\tjmp \t[eax]")
+    print("%endif")
+    print("ENDPROC vbox_glX%s" % func_name)
+    print("")
 
diff --git a/src/VBox/Additions/common/crOpenGL/NULLfuncs.py b/src/VBox/Additions/common/crOpenGL/NULLfuncs.py
old mode 100644
new mode 100755
index 1d52e9f..a642783
--- a/src/VBox/Additions/common/crOpenGL/NULLfuncs.py
+++ b/src/VBox/Additions/common/crOpenGL/NULLfuncs.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -12,46 +13,46 @@ keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE NULLfuncs.py SCRIPT */
 
 #include "cr_error.h"
 #include "stub.h"
-"""
+""")
 
 for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
 
-	print "static %s SPULOAD_APIENTRY NULL_%s( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-	print "{"
-	print "\t/* do nothing */"
-	print "\tcrWarning(\"YOU ARE CALLING A NULLED FUNCTION (%s)\");" % func_name
+	print("static %s SPULOAD_APIENTRY NULL_%s(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+	print("{")
+	print("\t/* do nothing */")
+	print("\tcrWarning(\"YOU ARE CALLING A NULLED FUNCTION (%s)\");" % func_name)
 	for (name, type, vecSize) in params:
-		print "\t(void) %s;" % name
+		print("\t(void) %s;" % name)
 	if return_type != "void":
-		print "\treturn 0;"
-	print "}"
-	print ""
+		print("\treturn 0;")
+	print("}")
+	print("")
 
 
-print "DECLEXPORT(SPUDispatchTable) stubNULLDispatch = {"
+print("DECLEXPORT(SPUDispatchTable) stubNULLDispatch = {")
 for func_name in keys:
-	print "\tNULL_%s," % (func_name)
-print "\tNULL,  /* copyList */"
-print "\tNULL,  /* copy_of */"
-print "\t0,     /* mark */"
-print "\tNULL   /* server */"
-print "};"
-
-print ""
-print "/* Declare and initialize the glim dispatch table here so that we */"
-print "/* can initialize all entries to no-op routines. */"
-print "SPUDispatchTable glim = {"
+	print("\tNULL_%s," % (func_name))
+print("\tNULL,  /* copyList */")
+print("\tNULL,  /* copy_of */")
+print("\t0,     /* mark */")
+print("\tNULL   /* server */")
+print("};")
+
+print("")
+print("/* Declare and initialize the glim dispatch table here so that we */")
+print("/* can initialize all entries to no-op routines. */")
+print("SPUDispatchTable glim = {")
 for func_name in keys:
-	print "\tNULL_%s," % (func_name)
-print "\tNULL,  /* copyList */"
-print "\tNULL,  /* copy_of */"
-print "\t0,     /* mark */"
-print "\tNULL   /* server */"
-print "};"
+	print("\tNULL_%s," % (func_name))
+print("\tNULL,  /* copyList */")
+print("\tNULL,  /* copy_of */")
+print("\t0,     /* mark */")
+print("\tNULL   /* server */")
+print("};")
diff --git a/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports.py b/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports.py
index 13497bd..48611f8 100755
--- a/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports.py
+++ b/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports.py
@@ -10,6 +10,7 @@ VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 """
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -22,14 +23,14 @@ def GenerateEntrypoints():
     # Get sorted list of dispatched functions.
     # The order is very important - it must match cr_opcodes.h
     # and spu_dispatch_table.h
-    print '%include "iprt/asmdefs.mac"'
-    print ""
-    print "%ifdef RT_ARCH_AMD64"
-    print "extern glim"
-    print "%else ; X86"
-    print "extern glim"
-    print "%endif"
-    print ""
+    print('%include "iprt/asmdefs.mac"')
+    print("")
+    print("%ifdef RT_ARCH_AMD64")
+    print("extern glim")
+    print("%else ; X86")
+    print("extern glim")
+    print("%endif")
+    print("")
 
     keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -40,19 +41,19 @@ def GenerateEntrypoints():
         if apiutil.Category(func_name) == "VBox":
             continue
 
-        print "BEGINPROC_EXPORTED gl%s" % func_name
-        print "%ifdef RT_ARCH_AMD64"
-        print "\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index)
-        print "%else ; X86"
-        print "\tjmp \t[glim+%d wrt ..gotpc]" % (4*index)
-        print "%endif"
-        print "ENDPROC gl%s" % func_name
-        print ""
+        print("BEGINPROC_EXPORTED gl%s" % func_name)
+        print("%ifdef RT_ARCH_AMD64")
+        print("\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index))
+        print("%else ; X86")
+        print("\tjmp \t[glim+%d wrt ..gotpc]" % (4*index))
+        print("%endif")
+        print("ENDPROC gl%s" % func_name)
+        print("")
 
 
-    print ';'
-    print '; Aliases'
-    print ';'
+    print(';')
+    print('; Aliases')
+    print(';')
 
     # Now loop over all the functions and take care of any aliases
     allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -69,28 +70,28 @@ def GenerateEntrypoints():
         if alias:
             # this dict lookup should never fail (raise an exception)!
             index = keys.index(alias)
-            print "BEGINPROC_EXPORTED gl%s" % func_name
-            print "%ifdef RT_ARCH_AMD64"
-            print "\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index)
-            print "%else ; X86"
-            print "\tjmp \t[glim+%d wrt ..gotpc]" % (4*index)
-            print "%endif"
-            print "ENDPROC gl%s" % func_name
-            print ""
+            print("BEGINPROC_EXPORTED gl%s" % func_name)
+            print("%ifdef RT_ARCH_AMD64")
+            print("\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index))
+            print("%else ; X86")
+            print("\tjmp \t[glim+%d wrt ..gotpc]" % (4*index))
+            print("%endif")
+            print("ENDPROC gl%s" % func_name)
+            print("")
 
 
-    print ';'
-    print '; No-op stubs'
-    print ';'
+    print(';')
+    print('; No-op stubs')
+    print(';')
 
     # Now generate no-op stub functions
     for func_name in allkeys:
         if "stub" in apiutil.ChromiumProps(func_name):
-            print "BEGINPROC_EXPORTED gl%s" % func_name
-            print "\tleave"
-            print "\tret"
-            print "ENDPROC gl%s" % func_name
-            print ""
+            print("BEGINPROC_EXPORTED gl%s" % func_name)
+            print("\tleave")
+            print("\tret")
+            print("ENDPROC gl%s" % func_name)
+            print("")
 
 
 GenerateEntrypoints()
diff --git a/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports_dri.py b/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports_dri.py
index f38d30a..1166b83 100755
--- a/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports_dri.py
+++ b/src/VBox/Additions/common/crOpenGL/SunOS_i386_exports_dri.py
@@ -10,6 +10,7 @@ VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 """
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -22,14 +23,14 @@ def GenerateEntrypoints():
     # Get sorted list of dispatched functions.
     # The order is very important - it must match cr_opcodes.h
     # and spu_dispatch_table.h
-    print '%include "iprt/asmdefs.mac"'
-    print ""
-    print "%ifdef RT_ARCH_AMD64"
-    print "extern glim"
-    print "%else ; X86"
-    print "extern glim"
-    print "%endif"
-    print ""
+    print('%include "iprt/asmdefs.mac"')
+    print("")
+    print("%ifdef RT_ARCH_AMD64")
+    print("extern glim")
+    print("%else ; X86")
+    print("extern glim")
+    print("%endif")
+    print("")
 
     keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -40,19 +41,19 @@ def GenerateEntrypoints():
         if apiutil.Category(func_name) == "VBox":
             continue
 
-        print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-        print "%ifdef RT_ARCH_AMD64"
-        print "\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index)
-        print "%else ; X86"
-        print "\tjmp \t[glim+%d wrt ..gotpc]" % (4*index)
-        print "%endif"
-        print "ENDPROC cr_gl%s" % func_name
-        print ""
+        print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+        print("%ifdef RT_ARCH_AMD64")
+        print("\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index))
+        print("%else ; X86")
+        print("\tjmp \t[glim+%d wrt ..gotpc]" % (4*index))
+        print("%endif")
+        print("ENDPROC cr_gl%s" % func_name)
+        print("")
 
 
-    print ';'
-    print '; Aliases'
-    print ';'
+    print(';')
+    print('; Aliases')
+    print(';')
 
     # Now loop over all the functions and take care of any aliases
     allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -69,28 +70,28 @@ def GenerateEntrypoints():
         if alias:
             # this dict lookup should never fail (raise an exception)!
             index = keys.index(alias)
-            print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-            print "%ifdef RT_ARCH_AMD64"
-            print "\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index)
-            print "%else ; X86"
-            print "\tjmp \t[glim+%d wrt ..gotpc]" % (4*index)
-            print "%endif"
-            print "ENDPROC cr_gl%s" % func_name
-            print ""
+            print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+            print("%ifdef RT_ARCH_AMD64")
+            print("\tjmp \t[glim+%d wrt rip wrt ..gotpcrel]" % (8*index))
+            print("%else ; X86")
+            print("\tjmp \t[glim+%d wrt ..gotpc]" % (4*index))
+            print("%endif")
+            print("ENDPROC cr_gl%s" % func_name)
+            print("")
 
 
-    print ';'
-    print '; No-op stubs'
-    print ';'
+    print(';')
+    print('; No-op stubs')
+    print(';')
 
     # Now generate no-op stub functions
     for func_name in allkeys:
         if "stub" in apiutil.ChromiumProps(func_name):
-            print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-            print "\tleave"
-            print "\tret"
-            print "ENDPROC cr_gl%s" % func_name
-            print ""
+            print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+            print("\tleave")
+            print("\tret")
+            print("ENDPROC cr_gl%s" % func_name)
+            print("")
 
 
 GenerateEntrypoints()
diff --git a/src/VBox/Additions/common/crOpenGL/SunOS_i386_glxapi_exports.py b/src/VBox/Additions/common/crOpenGL/SunOS_i386_glxapi_exports.py
index 16ac7bc..0659767 100755
--- a/src/VBox/Additions/common/crOpenGL/SunOS_i386_glxapi_exports.py
+++ b/src/VBox/Additions/common/crOpenGL/SunOS_i386_glxapi_exports.py
@@ -10,6 +10,7 @@ VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 """
 
+from __future__ import print_function
 import sys
 
 #Note, this should match the fakedri_glxfuncsList.h order
@@ -79,24 +80,24 @@ glx_functions = [
 "FreeContextEXT"
 ];
 
-print '%include "iprt/asmdefs.mac"'
-print ""
-print "%ifdef RT_ARCH_AMD64"
-print "extern glxim"
-print "%else ; X86"
-print "extern glxim"
-print "%endif"
-print ""
+print('%include "iprt/asmdefs.mac"')
+print("")
+print("%ifdef RT_ARCH_AMD64")
+print("extern glxim")
+print("%else ; X86")
+print("extern glxim")
+print("%endif")
+print("")
 
 for index in range(len(glx_functions)):
     func_name = glx_functions[index]
 
-    print "BEGINPROC_EXPORTED vbox_glX%s" % func_name
-    print "%ifdef RT_ARCH_AMD64"
-    print "\tjmp \t[glxim+%d wrt rip wrt ..gotpcrel]" % (8*index)
-    print "%else ; X86"
-    print "\tjmp \t[glxim+%d wrt ..gotpc]" % (4*index)
-    print "%endif"
-    print "ENDPROC vbox_glX%s" % func_name
-    print ""
+    print("BEGINPROC_EXPORTED vbox_glX%s" % func_name)
+    print("%ifdef RT_ARCH_AMD64")
+    print("\tjmp \t[glxim+%d wrt rip wrt ..gotpcrel]" % (8*index))
+    print("%else ; X86")
+    print("\tjmp \t[glxim+%d wrt ..gotpc]" % (4*index))
+    print("%endif")
+    print("ENDPROC vbox_glX%s" % func_name)
+    print("")
 
diff --git a/src/VBox/Additions/common/crOpenGL/cr_gl.py b/src/VBox/Additions/common/crOpenGL/cr_gl.py
old mode 100644
new mode 100755
index f1dd79b..5b8ec2e
--- a/src/VBox/Additions/common/crOpenGL/cr_gl.py
+++ b/src/VBox/Additions/common/crOpenGL/cr_gl.py
@@ -1,4 +1,5 @@
-print """
+from __future__ import print_function
+print("""
 /** @file
  * VBox OpenGL chromium functions header
  */
@@ -14,7 +15,7 @@ print """
  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  */
-"""
+""")
 # Copyright (c) 2001, Stanford University
 # All rights reserved.
 #
@@ -26,7 +27,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE cr_gl.py SCRIPT */
 #ifndef __CR_GL_H__
 #define __CR_GL_H__
@@ -40,7 +41,7 @@ print """
 #pragma warning( disable: 4055 )
 #endif
 
-"""
+""")
 
 
 # Extern-like declarations
@@ -58,7 +59,7 @@ for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
 
-	print "extern %s cr_gl%s( %s );" % (return_type, func_name,
-								  apiutil.MakeDeclarationString( params ))
+	print("extern %s cr_gl%s(%s);" % (return_type, func_name,
+								  apiutil.MakeDeclarationString( params )))
 
-print "#endif /* __CR_GL_H__ */"
+print("#endif /* __CR_GL_H__ */")
diff --git a/src/VBox/Additions/common/crOpenGL/defs.py b/src/VBox/Additions/common/crOpenGL/defs.py
old mode 100644
new mode 100755
index de0d031..c03f515
--- a/src/VBox/Additions/common/crOpenGL/defs.py
+++ b/src/VBox/Additions/common/crOpenGL/defs.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -12,7 +13,7 @@ apiutil.CopyrightDef()
 # NOTE: if we need a LIBRARY statement, we would need to create a defs-x86.py to generate a .def file for VBoxOGL-x86 library
 #print "LIBRARY VBoxOGL"
 #print "DESCRIPTION \"\"" - warning LNK4017: DESCRIPTION statement not supported for the target platform; ignored
-print "EXPORTS"
+print("EXPORTS")
 
 # XXX can't these values be automatically computed by analyzing parameters?
 
@@ -423,7 +424,7 @@ for func_name in keys:
     if func_name in noexport_special:
         continue
     try:
-        print "gl%s@%d = cr_gl%s" % (func_name,stack_sizes[func_name],func_name)
+        print("gl%s@%d = cr_gl%s" % (func_name,stack_sizes[func_name],func_name))
     except KeyError:
         pass
 
@@ -455,7 +456,7 @@ for func_name in ( "wglChoosePixelFormat",
            "wglGetPixelFormatAttribivEXT",
            "wglGetPixelFormatAttribfvEXT",
            "wglGetExtensionsStringEXT"):
-    print "%s = %s_prox" % (func_name,func_name)
+    print("%s = %s_prox" % (func_name,func_name))
 
 """
 for func_name in ( "CopyContext",
@@ -474,7 +475,7 @@ for func_name in ( "CopyContext",
     print "Drv%s@%d = wgl%s_prox" % (func_name,stack_sizes[func_name],func_name)
 """
 
-print """DrvCopyContext
+print("""DrvCopyContext
 DrvCreateContext
 DrvCreateLayerContext
 DrvDeleteContext
@@ -490,9 +491,9 @@ DrvSwapLayerBuffers
 DrvReleaseContext at 4 = DrvReleaseContext
 DrvSetContext at 12 = DrvSetContext
 DrvValidateVersion at 4 = DrvValidateVersion
-DrvSetPixelFormat at 8 = DrvSetPixelFormat"""
+DrvSetPixelFormat at 8 = DrvSetPixelFormat""")
 
-print """crCreateContext
+print("""crCreateContext
 crMakeCurrent
 crSwapBuffers
 crGetProcAddress
@@ -500,5 +501,5 @@ VBoxCreateContext
 VBoxCtxChromiumParameteriCR
 VBoxGetWindowId
 VBoxGetContextId
-VBoxFlushToHost"""
+VBoxFlushToHost""")
 #print "DllMain"
diff --git a/src/VBox/Additions/common/crOpenGL/defs64.py b/src/VBox/Additions/common/crOpenGL/defs64.py
old mode 100644
new mode 100755
index 68b3fd2..b1ac349
--- a/src/VBox/Additions/common/crOpenGL/defs64.py
+++ b/src/VBox/Additions/common/crOpenGL/defs64.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -11,7 +12,7 @@ apiutil.CopyrightDef()
 
 #print "LIBRARY VBoxOGL"
 #print "DESCRIPTION \"\"" - warning LNK4017: DESCRIPTION statement not supported for the target platform; ignored
-print "EXPORTS"
+print("EXPORTS")
 
 # XXX can't these values be automatically computed by analyzing parameters?
 
@@ -422,7 +423,7 @@ for func_name in keys:
     if func_name in noexport_special:
         continue
     if func_name in exports_special:
-        print "gl%s = cr_gl%s" % (func_name,func_name)
+        print("gl%s = cr_gl%s" % (func_name,func_name))
 
 for func_name in ( "wglChoosePixelFormat", 
            "wglCopyContext",
@@ -452,9 +453,9 @@ for func_name in ( "wglChoosePixelFormat",
            "wglGetPixelFormatAttribivEXT",
            "wglGetPixelFormatAttribfvEXT",
            "wglGetExtensionsStringEXT"):
-    print "%s = %s_prox" % (func_name,func_name)
+    print("%s = %s_prox" % (func_name,func_name))
 
-print """DrvCopyContext
+print("""DrvCopyContext
 DrvCreateContext
 DrvCreateLayerContext
 DrvDeleteContext
@@ -470,9 +471,9 @@ DrvSwapLayerBuffers
 DrvReleaseContext = DrvReleaseContext
 DrvSetContext = DrvSetContext
 DrvValidateVersion = DrvValidateVersion
-DrvSetPixelFormat = DrvSetPixelFormat"""
+DrvSetPixelFormat = DrvSetPixelFormat""")
 
-print """crCreateContext
+print("""crCreateContext
 crMakeCurrent
 crSwapBuffers
 crGetProcAddress
@@ -480,5 +481,5 @@ VBoxCreateContext
 VBoxCtxChromiumParameteriCR
 VBoxGetWindowId
 VBoxGetContextId
-VBoxFlushToHost"""
+VBoxFlushToHost""")
 #print "DllMain"
diff --git a/src/VBox/Additions/common/crOpenGL/entrypoints.py b/src/VBox/Additions/common/crOpenGL/entrypoints.py
old mode 100644
new mode 100755
index c2efd17..a1a3a1f
--- a/src/VBox/Additions/common/crOpenGL/entrypoints.py
+++ b/src/VBox/Additions/common/crOpenGL/entrypoints.py
@@ -10,6 +10,7 @@ and the special Chromium meta/glue functions.
 """
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -22,19 +23,19 @@ def GenerateEntrypoints(hacks = []):
 
     apiutil.CopyrightC()
 
-    print '#define GL_GLEXT_PROTOTYPES'
-    print '#include <stdio.h>'
-    print '#include <stdlib.h>'
-    print '#include <GL/gl.h>'
-    print '#include "chromium.h"'
-    print '#include "stub.h"'
-    print '#include "dri_glx.h"'
-    print ''
-    print '#ifdef __GNUC__';
-    print '# if (__GNUC__ << 16) + __GNUC_MINOR__ >= 0x40002';
-    print '#  pragma GCC diagnostic ignored "-Wunused-parameter"';
-    print '# endif';
-    print '#endif';
+    print('#define GL_GLEXT_PROTOTYPES')
+    print('#include <stdio.h>')
+    print('#include <stdlib.h>')
+    print('#include <GL/gl.h>')
+    print('#include "chromium.h"')
+    print('#include "stub.h"')
+    print('#include "dri_glx.h"')
+    print('')
+    print('#ifdef __GNUC__')
+    print('# if (__GNUC__ << 16) + __GNUC_MINOR__ >= 0x40002')
+    print('#  pragma GCC diagnostic ignored "-Wunused-parameter"')
+    print('# endif')
+    print('#endif')
 
 
     # Get sorted list of dispatched functions.
@@ -52,62 +53,62 @@ def GenerateEntrypoints(hacks = []):
         params = apiutil.Parameters(func_name)
 
         if func_name in hacks:
-            print "/* hacked entrypoint: %s */" % func_name
+            print("/* hacked entrypoint: %s */" % func_name)
             if func_name == "TexImage3D":
                 # Pretty common: internalformat is GLenum, not GLint
-                print "void glTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
-                print "{"
-                print "\tglim.TexImage3D( target, level, (GLint) internalformat, width, height, depth, border, format, type, pixels );"
-                print "}"
+                print("void glTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )")
+                print("{")
+                print("\tglim.TexImage3D( target, level, (GLint) internalformat, width, height, depth, border, format, type, pixels );")
+                print("}")
             elif func_name == "TexImage2D":
                 # Pretty common: internalformat is GLenum, not GLint
-                print "void glTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
-                print "{"
-                print "\tglim.TexImage2D( target, level, (GLint) internalformat, width, height, border, format, type, pixels );"
-                print "}"
+                print("void glTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )")
+                print("{")
+                print("\tglim.TexImage2D( target, level, (GLint) internalformat, width, height, border, format, type, pixels );")
+                print("}")
             elif func_name == "TexImage1D":
                 # Pretty common: internalformat is GLenum, not GLint
-                print "void glTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
-                print "{"
-                print "\tglim.TexImage1D( target, level, (GLint) internalformat, width, border, format, type, pixels );"
-                print "}"
+                print("void glTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )")
+                print("{")
+                print("\tglim.TexImage1D( target, level, (GLint) internalformat, width, border, format, type, pixels );")
+                print("}")
             elif func_name == "EdgeFlagPointer":
                 # second arg is GLboolean instead of GLvoid
-                print "void glEdgeFlagPointer( GLsizei stride, const GLboolean *pointer )"
-                print "{"
-                print "\tglim.EdgeFlagPointer( stride, pointer );"
-                print "}"
+                print("void glEdgeFlagPointer( GLsizei stride, const GLboolean *pointer )")
+                print("{")
+                print("\tglim.EdgeFlagPointer( stride, pointer );")
+                print("}")
             elif func_name == "ProgramParameters4fvNV":
-                print "void glProgramParameters4fvNV( GLenum target, GLuint index, GLuint num, const GLfloat *params )"
-                print "{"
-                print "\tglim.ProgramParameters4fvNV( target, index, num, params );"
-                print "}"
+                print("void glProgramParameters4fvNV( GLenum target, GLuint index, GLuint num, const GLfloat *params )")
+                print("{")
+                print("\tglim.ProgramParameters4fvNV( target, index, num, params );")
+                print("}")
             elif func_name == "MultiDrawElementsEXT":
-                print "void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)"
-                print "{"
-                print "\tglim.MultiDrawElementsEXT(mode, count,type, indices, primcount);"
-                print "}"
+                print("void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)")
+                print("{")
+                print("\tglim.MultiDrawElementsEXT(mode, count,type, indices, primcount);")
+                print("}")
             elif func_name == "ProgramParameters4dvNV":
-                print "void glProgramParameters4dvNV( GLenum target, GLuint index, GLuint num, const GLdouble *params )"
-                print "{"
-                print "\tglim.ProgramParameters4dvNV( target, index, num, params );"
-                print "}"
+                print("void glProgramParameters4dvNV( GLenum target, GLuint index, GLuint num, const GLdouble *params )")
+                print("{")
+                print("\tglim.ProgramParameters4dvNV( target, index, num, params );")
+                print("}")
         else:
             # the usual path
-            print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-            print ""
-            print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-            print "{"
-            print "\t",
+            print("%s VBOXGLTAG(gl%s)(%s);" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+            print("")
+            print("%s VBOXGLTAG(gl%s)(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+            print("{")
+            print("\t", end="")
             if return_type != "void":
-                print "return ",
-            print "glim.%s( %s );" % (func_name, apiutil.MakeCallString(params))
-            print "}"
-            print ""
+                print("return ", end=" ")
+            print("glim.%s(%s);" % (func_name, apiutil.MakeCallString(params)))
+            print("}")
+            print("")
 
-    print '/*'
-    print '* Aliases'
-    print '*/'
+    print('/*')
+    print('* Aliases')
+    print('*/')
 
     # Now loop over all the functions and take care of any aliases
     allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -123,44 +124,44 @@ def GenerateEntrypoints(hacks = []):
         alias = apiutil.Alias(func_name)
         if alias:
             if func_name in hacks:
-                print "/* hacked entrypoint: %s */" % func_name
+                print("/* hacked entrypoint: %s */" % func_name)
                 if func_name == "MultiDrawArrays":
-                    print "void glMultiDrawArrays( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount )"
-                    print "{"
-                    print "\tglim.MultiDrawArraysEXT( mode, (GLint*)first, (GLsizei*)count, primcount );"
-                    print "}"
+                    print("void glMultiDrawArrays( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount )")
+                    print("{")
+                    print("\tglim.MultiDrawArraysEXT( mode, (GLint*)first, (GLsizei*)count, primcount );")
+                    print("}")
                 elif func_name == "BufferData":
-                    print "void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)"
-                    print "{"
-                    print "\tglim.BufferDataARB(target, size, data, usage);"
-                    print "}"
+                    print("void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)")
+                    print("{")
+                    print("\tglim.BufferDataARB(target, size, data, usage);")
+                    print("}")
                 elif func_name == "BufferSubData":
-                    print "void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)"
-                    print "{"
-                    print "\tglim.BufferSubDataARB(target, offset, size, data);"
-                    print "}"
+                    print("void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)")
+                    print("{")
+                    print("\tglim.BufferSubDataARB(target, offset, size, data);")
+                    print("}")
                 elif func_name == "GetBufferSubData":
-                    print "void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)"
-                    print "{"
-                    print "\tglim.GetBufferSubDataARB(target, offset, size, data);"
-                    print "}"
+                    print("void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)")
+                    print("{")
+                    print("\tglim.GetBufferSubDataARB(target, offset, size, data);")
+                    print("}")
             else:
                 return_type = apiutil.ReturnType(func_name)
                 params = apiutil.Parameters(func_name)
-                print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-                print ""
-                print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-                print "{"
-                print "\t",
+                print("%s VBOXGLTAG(gl%s)(%s);" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+                print("")
+                print("%s VBOXGLTAG(gl%s)(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+                print("{")
+                print("\t", end="")
                 if return_type != "void":
-                    print "return ",
-                print "glim.%s( %s );" % (alias, apiutil.MakeCallString(params))
-                print "}"
-                print ""
+                    print("return ", end=" ")
+                print("glim.%s(%s);" % (alias, apiutil.MakeCallString(params)))
+                print("}")
+                print("")
 
-    print '/*'
-    print '* No-op stubs'
-    print '*/'
+    print('/*')
+    print('* No-op stubs')
+    print('*/')
 
     # Now generate no-op stub functions
     for func_name in allkeys:
@@ -168,13 +169,13 @@ def GenerateEntrypoints(hacks = []):
             return_type = apiutil.ReturnType(func_name)
             params = apiutil.Parameters(func_name)
 
-            print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-            print ""
-            print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-            print "{"
+            print("%s VBOXGLTAG(gl%s)(%s);" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+            print("")
+            print("%s VBOXGLTAG(gl%s)(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+            print("{")
             if return_type != "void":
-                print "return (%s) 0" % return_type
-            print "}"
-            print ""
+                print("return (%s) 0" % return_type)
+            print("}")
+            print("")
 
 
diff --git a/src/VBox/Additions/common/crOpenGL/feedback/feedback.py b/src/VBox/Additions/common/crOpenGL/feedback/feedback.py
old mode 100644
new mode 100755
index 4c1e121..181b23f
--- a/src/VBox/Additions/common/crOpenGL/feedback/feedback.py
+++ b/src/VBox/Additions/common/crOpenGL/feedback/feedback.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - generated by feedback.py */
 #include <stdio.h>
 #include "cr_spu.h"
@@ -19,7 +20,7 @@ print """
 #include "cr_packfunctions.h"
 #include "cr_glstate.h"
 
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -27,52 +28,52 @@ for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
 	if apiutil.FindSpecial( "feedback", func_name ):
-		print 'static %s FEEDBACKSPU_APIENTRY feedbackspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString(params) )
-		print '{'
-		print '\tfeedback_spu.super.%s( %s );' % ( func_name, apiutil.MakeCallString(params) )
-		print '}'
+		print('static %s FEEDBACKSPU_APIENTRY feedbackspu_%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString(params) ))
+		print('{')
+		print('\tfeedback_spu.super.%s(%s);' % ( func_name, apiutil.MakeCallString(params) ))
+		print('}')
 
 
 
-print """
-#define CHANGE( name, func ) crSPUChangeInterface( (void *)&(feedback_spu.self), (void *)feedback_spu.self.name, (void *)((SPUGenericFunction) func) )
-#define CHANGESWAP( name, swapfunc, regfunc ) crSPUChangeInterface( (void *)&(feedback_spu.self), (void *)feedback_spu.self.name, (void *)((SPUGenericFunction) (feedback_spu.swap ? swapfunc: regfunc )) )
+print("""
+#define CHANGE(name, func) crSPUChangeInterface((void *)&(feedback_spu.self), (void *)feedback_spu.self.name, (void *)((SPUGenericFunction) func))
+#define CHANGESWAP(name, swapfunc, regfunc) crSPUChangeInterface( (void *)&(feedback_spu.self), (void *)feedback_spu.self.name, (void *)((SPUGenericFunction) (feedback_spu.swap ? swapfunc: regfunc )))
 
 static void __loadFeedbackAPI( void )
 {
-"""
+""")
 for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
 	if apiutil.FindSpecial( "feedback", func_name ):
-		print '\tCHANGE( %s, crStateFeedback%s );' % (func_name, func_name )
-print """
+		print('\tCHANGE(%s, crStateFeedback%s);' % (func_name, func_name ))
+print("""
 }
 
 static void __loadSelectAPI( void )
 {
-"""
+""")
 for func_name in keys:
 	if apiutil.FindSpecial( "select", func_name ):
-		print '\tCHANGE( %s, crStateSelect%s );' % (func_name, func_name )
+		print('\tCHANGE(%s, crStateSelect%s);' % (func_name, func_name ))
 	elif apiutil.FindSpecial( "feedback", func_name ):
-		print '\tCHANGE( %s, feedbackspu_%s );' % (func_name, func_name )
-print """
+		print('\tCHANGE(%s, feedbackspu_%s);' % (func_name, func_name ))
+print("""
 }
 
 static void __loadRenderAPI( void )
 {
-"""
+""")
 
 for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	if apiutil.FindSpecial( "feedback", func_name ) or apiutil.FindSpecial( "select", func_name ):
-		print '\tCHANGE( %s, feedbackspu_%s );' % (func_name, func_name )
-print """
+		print('\tCHANGE(%s, feedbackspu_%s);' % (func_name, func_name ))
+print("""
 }
-"""
+""")
 
-print """
+print("""
 static GLint FEEDBACKSPU_APIENTRY feedbackspu_RenderMode ( GLenum mode )
 {
 	feedback_spu.render_mode = mode;
@@ -210,12 +211,12 @@ static void FEEDBACKSPU_APIENTRY feedbackspu_GetIntegerv( GLenum pname, GLint *p
 }
 
 SPUNamedFunctionTable _cr_feedback_table[] = {
-"""
+""")
 
 for func_name in keys:
 	if apiutil.FindSpecial( "feedback_state", func_name ):
-		print '\t{ "%s", (SPUGenericFunction) feedbackspu_%s }, ' % ( func_name, func_name )
-print """
+		print('\t{ "%s", (SPUGenericFunction) feedbackspu_%s }, ' % ( func_name, func_name ))
+print("""
 	{ "GetBooleanv", (SPUGenericFunction) feedbackspu_GetBooleanv },
 	{ "GetDoublev", (SPUGenericFunction) feedbackspu_GetDoublev },
 	{ "GetFloatv", (SPUGenericFunction) feedbackspu_GetFloatv },
@@ -266,4 +267,4 @@ print """
 	{ "RenderMode", (SPUGenericFunction) feedbackspu_RenderMode },
 	{ NULL, NULL }
 };
-"""
+""")
diff --git a/src/VBox/Additions/common/crOpenGL/feedback/feedback_funcs.py b/src/VBox/Additions/common/crOpenGL/feedback/feedback_funcs.py
old mode 100644
new mode 100755
index 29e9052..d3c4083
--- a/src/VBox/Additions/common/crOpenGL/feedback/feedback_funcs.py
+++ b/src/VBox/Additions/common/crOpenGL/feedback/feedback_funcs.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY feedback_funcs.py SCRIPT */
 #ifndef CR_STATE_FEEDBACK_FUNCS_H
 #define CR_STATE_FEEDBACK_FUNCS_H
@@ -23,17 +24,17 @@ print """
 #define STATE_APIENTRY
 #endif
 
-#define STATE_UNUSED(x) ((void)x)"""
+#define STATE_UNUSED(x) ((void)x)""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 for func_name in apiutil.AllSpecials( "feedback" ):
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
-	print '%s STATE_APIENTRY crStateFeedback%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
+	print('%s STATE_APIENTRY crStateFeedback%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
 
 for func_name in apiutil.AllSpecials( "select" ):
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
-	print '%s STATE_APIENTRY crStateSelect%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
-print '\n#endif /* CR_STATE_FEEDBACK_FUNCS_H */'
+	print('%s STATE_APIENTRY crStateSelect%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+print('\n#endif /* CR_STATE_FEEDBACK_FUNCS_H */')
diff --git a/src/VBox/Additions/common/crOpenGL/feedback/feedback_state.py b/src/VBox/Additions/common/crOpenGL/feedback/feedback_state.py
old mode 100644
new mode 100755
index cb0a74a..01bab42
--- a/src/VBox/Additions/common/crOpenGL/feedback/feedback_state.py
+++ b/src/VBox/Additions/common/crOpenGL/feedback/feedback_state.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,11 +11,11 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 #include "cr_server.h"
 #include "feedbackspu.h"
 #include "feedbackspu_proto.h"
-"""
+""")
 custom = ["CreateContext", "VBoxCreateContext", "MakeCurrent", "DestroyContext"]
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
@@ -25,9 +26,9 @@ for func_name in keys:
             continue
         return_type = apiutil.ReturnType(func_name)
         params = apiutil.Parameters(func_name)
-        print '%s FEEDBACKSPU_APIENTRY feedbackspu_%s( %s )' % (return_type, func_name, apiutil.MakeDeclarationString(params))
-        print '{'
-        print '\tcrState%s( %s );' % (func_name, apiutil.MakeCallString(params))
-        print ''
-        print '\tfeedback_spu.super.%s( %s );' % (func_name, apiutil.MakeCallString(params))
-        print '}'
+        print('%s FEEDBACKSPU_APIENTRY feedbackspu_%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+        print('{')
+        print('\tcrState%s(%s);' % (func_name, apiutil.MakeCallString(params)))
+        print('')
+        print('\tfeedback_spu.super.%s(%s);' % (func_name, apiutil.MakeCallString(params)))
+        print('}')
diff --git a/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_proto.py b/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_proto.py
old mode 100644
new mode 100755
index 875b5cf..92a5c1c
--- a/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_proto.py
+++ b/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_proto.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - generated by feedback.py */
 
 #ifndef FEEDBACKSPU_PROTO_H
@@ -18,7 +19,7 @@ print """
 
 #include "feedbackspu.h"
 
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -26,9 +27,9 @@ for func_name in keys:
 	if apiutil.FindSpecial( "feedback_state", func_name ):
 		return_type = apiutil.ReturnType(func_name)
 		params = apiutil.Parameters(func_name)
-		print 'extern %s FEEDBACKSPU_APIENTRY feedbackspu_%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
+		print('extern %s FEEDBACKSPU_APIENTRY feedbackspu_%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
 
 
-print """
+print("""
 #endif
-"""
+""")
diff --git a/src/VBox/Additions/common/crOpenGL/getprocaddress.py b/src/VBox/Additions/common/crOpenGL/getprocaddress.py
old mode 100644
new mode 100755
index 23cde45..39cfdf9
--- a/src/VBox/Additions/common/crOpenGL/getprocaddress.py
+++ b/src/VBox/Additions/common/crOpenGL/getprocaddress.py
@@ -3,13 +3,14 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE getprocaddress.py SCRIPT */
 
 #include "chromium.h"
@@ -29,7 +30,7 @@ struct name_address {
 };
 
 static struct name_address functions[] = {
-"""
+""")
 
 
 keys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -47,13 +48,13 @@ for func_name in keys:
 	name = "gl" + func_name
 	address = "VBOXGLTAG(gl" + func_name + ")"
 	if wrap:
-		print '#ifdef CR_%s' % wrap
-	print '\t{ "%s", (CR_PROC) %s },' % (name, address)
+		print('#ifdef CR_%s' % wrap)
+	print('\t{ "%s", (CR_PROC) %s },' % (name, address))
 	if wrap:
-		print '#endif'
+		print('#endif')
 
 
-print "\t/* Chromium binding/glue functions */"
+print("\t/* Chromium binding/glue functions */")
 
 for func_name in keys:
 	if (func_name == "Writeback" or
@@ -62,10 +63,10 @@ for func_name in keys:
 		func_name == "GetAttribsLocations"):
 		continue
 	if apiutil.Category(func_name) == "Chromium":
-		print '\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name)
+		print('\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name))
 
 
-print """
+print("""
 	{ NULL, NULL }
 };
 
@@ -86,8 +87,8 @@ CR_PROC CR_APIENTRY crGetProcAddress( const char *name )
 #undef GLXAPI_ENTRY
 
     /*CR_EXT_texture_from_pixmap*/
-    if (!crStrcmp( name, "glXBindTexImageEXT" )) return (CR_PROC) VBOXGLXTAG(glXBindTexImageEXT);
-    if (!crStrcmp( name, "glXReleaseTexImageEXT" )) return (CR_PROC) VBOXGLXTAG(glXReleaseTexImageEXT);
+    if (!crStrcmp(name, "glXBindTexImageEXT")) return (CR_PROC) VBOXGLXTAG(glXBindTexImageEXT);
+    if (!crStrcmp(name, "glXReleaseTexImageEXT")) return (CR_PROC) VBOXGLXTAG(glXReleaseTexImageEXT);
 
 #if defined(Linux) && defined(CR_EXT_framebuffer_blit)
     /* Hacky way to make gnome3 happy on ubuntu 11.04, even though glBlitFramebuffer is part of OpenGL 3.0 spec,
@@ -101,7 +102,7 @@ CR_PROC CR_APIENTRY crGetProcAddress( const char *name )
 	return NULL;
 }
 
-"""
+""")
 
 
 
@@ -115,10 +116,10 @@ print_foo = """
 		wglChoosePixelFormatFunc_t wglChoosePixelFormatEXT = NULL;
 		wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = NULL;
 		wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = NULL;
-		if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
-		if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
-		if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
-		if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
+		if (!crStrcmp(name, "wglGetExtensionsStringEXT")) return (CR_PROC) wglGetExtensionsStringEXT;
+		if (!crStrcmp(name, "wglChoosePixelFormatEXT")) return (CR_PROC) wglChoosePixelFormatEXT;
+		if (!crStrcmp(name, "wglGetPixelFormatAttribivEXT")) return (CR_PROC) wglGetPixelFormatAttribivEXT;
+		if (!crStrcmp(name, "wglGetPixelFormatAttribfvEXT")) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
 	}
 #endif
 """
diff --git a/src/VBox/Additions/common/crOpenGL/pack/pack.py b/src/VBox/Additions/common/crOpenGL/pack/pack.py
old mode 100644
new mode 100755
index 8bad6ce..d7a81fb
--- a/src/VBox/Additions/common/crOpenGL/pack/pack.py
+++ b/src/VBox/Additions/common/crOpenGL/pack/pack.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -13,7 +14,7 @@ keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY pack.py SCRIPT */
 #include <stdio.h>
 #include "cr_string.h"
@@ -21,17 +22,17 @@ print """
 #include "packspu.h"
 #include "cr_packfunctions.h"
 #include "packspu_proto.h"
-"""
+""")
 
 num_funcs = len(keys) - len(apiutil.AllSpecials('packspu_unimplemented'))
-print 'SPUNamedFunctionTable _cr_pack_table[%d];' % (num_funcs+1)
+print('SPUNamedFunctionTable _cr_pack_table[%d];' % (num_funcs+1))
 
-print """
-static void __fillin( int offset, char *name, SPUGenericFunction func )
+print("""
+static void __fillin(int offset, char *name, SPUGenericFunction func)
 {
-    _cr_pack_table[offset].name = crStrdup( name );
+    _cr_pack_table[offset].name = crStrdup(name);
     _cr_pack_table[offset].fn = func;
-}"""
+}""")
 
 pack_specials = []
 
@@ -42,15 +43,15 @@ for func_name in keys:
         apiutil.FindSpecial( "packspu_vertex", func_name )):
       pack_specials.append( func_name )
 
-print '\nvoid packspuCreateFunctions( void )'
-print '{'
+print('\nvoid packspuCreateFunctions( void )')
+print('{')
 for index in range(len(keys)):
     func_name = keys[index]
     if apiutil.FindSpecial( "packspu_unimplemented", func_name ):
         continue
     if func_name in pack_specials:
-        print '\t__fillin( %3d, "%s", (SPUGenericFunction) packspu_%s );' % (index, func_name, func_name )
+        print('\t__fillin(%3d, "%s", (SPUGenericFunction) packspu_%s);' % (index, func_name, func_name ))
     else:
-        print '\t__fillin( %3d, "%s", (SPUGenericFunction) (pack_spu.swap ? crPack%sSWAP : crPack%s) );' % (index, func_name, func_name, func_name )
-print '\t__fillin( %3d, NULL, NULL );' % num_funcs
-print '}'
+        print('\t__fillin(%3d, "%s", (SPUGenericFunction) (pack_spu.swap ? crPack%sSWAP : crPack%s));' % (index, func_name, func_name, func_name ))
+print('\t__fillin(%3d, NULL, NULL);' % num_funcs)
+print('}')
diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py b/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py
old mode 100644
new mode 100755
index 9a26050..2195cab
--- a/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py
+++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """/* DO NOT EDIT - AUTOMATICALLY GENERATED BY packspu_beginend.py */
+print("""/* DO NOT EDIT - AUTOMATICALLY GENERATED BY packspu_beginend.py */
 #include "packspu.h"
 #include "assert.h"
 #include "cr_packfunctions.h"
@@ -156,21 +157,21 @@ static void RunState( void )
     }
     DoVertex();
 }
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 for func_name in apiutil.AllSpecials( "packspu_vertex" ):
     params = apiutil.Parameters(func_name)
-    print 'void PACKSPU_APIENTRY packspu_%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params) )
-    print '{'
-    print '\tif (pack_spu.swap)'
-    print '\t{'
-    print '\t\tcrPack%sSWAP( %s );' % ( func_name, apiutil.MakeCallString( params ) )
-    print '\t}'
-    print '\telse'
-    print '\t{'
-    print '\t\tcrPack%s( %s );' % ( func_name, apiutil.MakeCallString( params ) )
-    print '\t}'
-    print '\tRunState();'
-    print '}'
+    print('void PACKSPU_APIENTRY packspu_%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
+    print('{')
+    print('\tif (pack_spu.swap)')
+    print('\t{')
+    print('\t\tcrPack%sSWAP(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
+    print('\t}')
+    print('\telse')
+    print('\t{')
+    print('\t\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
+    print('\t}')
+    print('\tRunState();')
+    print('}')
diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py b/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py
old mode 100644
new mode 100755
index d39a55e..5742bcb
--- a/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py
+++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - this file generated by packspu_flush.py script */
 
 /* These are otherwise ordinary functions which require that the buffer be
@@ -20,22 +21,22 @@ print """
 #include "cr_packfunctions.h"
 #include "packspu.h"
 #include "packspu_proto.h"
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 for func_name in apiutil.AllSpecials( "packspu_flush" ):
     params = apiutil.Parameters(func_name)
-    print 'void PACKSPU_APIENTRY packspu_%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params))
-    print '{'
-    print '\tGET_THREAD(thread);'
-    print '\tif (pack_spu.swap)'
-    print '\t{'
-    print '\t\tcrPack%sSWAP( %s );' % ( func_name, apiutil.MakeCallString( params ) )
-    print '\t}'
-    print '\telse'
-    print '\t{'
-    print '\t\tcrPack%s( %s );' % ( func_name, apiutil.MakeCallString( params ) )
-    print '\t}'
-    print '\tpackspuFlush( (void *) thread );'
-    print '}\n'
+    print('void PACKSPU_APIENTRY packspu_%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params)))
+    print('{')
+    print('\tGET_THREAD(thread);')
+    print('\tif (pack_spu.swap)')
+    print('\t{')
+    print('\t\tcrPack%sSWAP(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
+    print('\t}')
+    print('\telse')
+    print('\t{')
+    print('\t\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
+    print('\t}')
+    print('\tpackspuFlush( (void *) thread );')
+    print('}\n')
diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py b/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
index 75bb783..5a4a49d 100755
--- a/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
+++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,16 +11,16 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY packspu_get.py SCRIPT */
 #include "packspu.h"
 #include "cr_packfunctions.h"
 #include "cr_net.h"
 #include "cr_mem.h"
 #include "packspu_proto.h"
-"""
+""")
 
-print """
+print("""
 static GLboolean crPackIsPixelStoreParm(GLenum pname)
 {
     if (pname == GL_UNPACK_ALIGNMENT
@@ -45,7 +46,7 @@ static GLboolean crPackIsPixelStoreParm(GLenum pname)
     }
     return GL_FALSE;
 }
-"""
+""")
 
 from get_sizes import *
 
@@ -84,21 +85,21 @@ for func_name in keys:
         continue
 
     if "get" in apiutil.Properties(func_name):
-        print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
-        print '{'
-        print '\tGET_THREAD(thread);'
-        print '\tint writeback = 1;'
+        print('%s PACKSPU_APIENTRY packspu_%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) ))
+        print('{')
+        print('\tGET_THREAD(thread);')
+        print('\tint writeback = 1;')
         if return_type != 'void':
-            print '\t%s return_val = (%s) 0;' % (return_type, return_type)
+            print('\t%s return_val = (%s) 0;' % (return_type, return_type))
             params.append( ("&return_val", "foo", 0) )
-        if (func_name in easy_swaps.keys() and easy_swaps[func_name] != '0') or func_name in simple_funcs or func_name in hard_funcs.keys():
-            print '\tunsigned int i;'
-        print '\tif (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))'
-        print '\t{'
-        print '\t\tcrError( "packspu_%s doesn\'t work when there\'s no actual network involved!\\nTry using the simplequery SPU in your chain!" );' % func_name
-        print '\t}'
+        if (func_name in easy_swaps and easy_swaps[func_name] != '0') or func_name in simple_funcs or func_name in hard_funcs:
+            print('\tunsigned int i;')
+        print('\tif (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))')
+        print('\t{')
+        print('\t\tcrError( "packspu_%s doesn\'t work when there\'s no actual network involved!\\nTry using the simplequery SPU in your chain!" );' % func_name)
+        print('\t}')
         if func_name in simple_funcs:
-            print """
+            print("""
     if (crPackIsPixelStoreParm(pname)
         || pname == GL_DRAW_BUFFER
 #ifdef CR_OPENGL_VERSION_1_3
@@ -161,10 +162,10 @@ for func_name in keys:
             }
             
         }
-            """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
+            """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name))
             
         if func_name in vertattr_get_funcs:
-            print """
+            print("""
     if (pname != GL_CURRENT_VERTEX_ATTRIB_ARB)
     {
 #ifdef DEBUG
@@ -188,62 +189,62 @@ for func_name in keys:
 #endif
         return;
     } 
-            """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
+            """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name))
 
         params.append( ("&writeback", "foo", 0) )
-        print '\tif (pack_spu.swap)'
-        print '\t{'
-        print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
-        print '\t}'
-        print '\telse'
-        print '\t{'
-        print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
-        print '\t}'
-        print '\tpackspuFlush( (void *) thread );'
-        print '\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);'
+        print('\tif (pack_spu.swap)')
+        print('\t{')
+        print('\t\tcrPack%sSWAP(%s);' % (func_name, apiutil.MakeCallString( params ) ))
+        print('\t}')
+        print('\telse')
+        print('\t{')
+        print('\t\tcrPack%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
+        print('\t}')
+        print('\tpackspuFlush( (void *) thread );')
+        print('\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);')
 
 
 
         lastParamName = params[-2][0]
         if return_type != 'void':
-            print '\tif (pack_spu.swap)'
-            print '\t{'
-            print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
-            print '\t}'
-            print '\treturn return_val;'
-        if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
+            print('\tif (pack_spu.swap)')
+            print('\t{')
+            print('\t\treturn_val = (%s) SWAP32(return_val);' % return_type)
+            print('\t}')
+            print('\treturn return_val;')
+        if func_name in easy_swaps and easy_swaps[func_name] != '0':
             limit = easy_swaps[func_name]
-            print '\tif (pack_spu.swap)'
-            print '\t{'
-            print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
-            print '\t\t{'
+            print('\tif (pack_spu.swap)')
+            print('\t{')
+            print('\t\tfor (i = 0; i < %s; i++)' % limit)
+            print('\t\t{')
             if params[-2][1].find( "double" ) > -1:
-                print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
+                print('\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName))
             else:
-                print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
-            print '\t\t}'
-            print '\t}'
+                print('\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName))
+            print('\t\t}')
+            print('\t}')
         for index in range(len(simple_funcs)):
             if simple_funcs[index] == func_name:
-                print '\tif (pack_spu.swap)'
-                print '\t{'
-                print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
-                print '\t\t{'
+                print('\tif (pack_spu.swap)')
+                print('\t{')
+                print('\t\tfor (i = 0; i < __numValues(pname); i++)')
+                print('\t\t{')
                 if simple_swaps[index] == 'SWAPDOUBLE':
-                    print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
+                    print('\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName))
                 else:
-                    print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
-                print '\t\t}'
-                print '\t}'
-        if func_name in hard_funcs.keys():
-            print '\tif (pack_spu.swap)'
-            print '\t{'
-            print '\t\tfor (i = 0 ; i < crStateHlpComponentsCount(pname) ; i++)'
-            print '\t\t{'
+                    print('\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName))
+                print('\t\t}')
+                print('\t}')
+        if func_name in hard_funcs:
+            print('\tif (pack_spu.swap)')
+            print('\t{')
+            print('\t\tfor (i = 0; i < crStateHlpComponentsCount(pname); i++)')
+            print('\t\t{')
             if hard_funcs[func_name] == 'SWAPDOUBLE':
-                print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
+                print('\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName))
             else:
-                print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
-            print '\t\t}'
-            print '\t}'
-        print '}\n'
+                print('\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName))
+            print('\t\t}')
+            print('\t}')
+        print('}\n')
diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_proto.py b/src/VBox/Additions/common/crOpenGL/pack/packspu_proto.py
old mode 100644
new mode 100755
index 6ae1108..5d33567
--- a/src/VBox/Additions/common/crOpenGL/pack/packspu_proto.py
+++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_proto.py
@@ -3,13 +3,14 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY packspu_proto.py SCRIPT */
 
 #ifndef PACKSPU_FUNCTIONS_H
@@ -20,7 +21,7 @@ print """
 #include "cr_spu.h"
 #include "packspu.h"
 #include "cr_packfunctions.h"
-"""
+""")
 
 
 pack_specials = []
@@ -41,9 +42,9 @@ for func_name in keys:
     if func_name in pack_specials:
         return_type = apiutil.ReturnType(func_name)
         params = apiutil.Parameters(func_name)
-        print 'extern %s PACKSPU_APIENTRY packspu_%s( %s );' % ( return_type, func_name, apiutil.MakeDeclarationString(params) )
+        print('extern %s PACKSPU_APIENTRY packspu_%s(%s);' % ( return_type, func_name, apiutil.MakeDeclarationString(params) ))
 
 
-print """
+print("""
 #endif
-"""
+""")
diff --git a/src/VBox/Additions/common/crOpenGL/passthrough/passthrough.py b/src/VBox/Additions/common/crOpenGL/passthrough/passthrough.py
old mode 100644
new mode 100755
index 7b53129..ec7e27c
--- a/src/VBox/Additions/common/crOpenGL/passthrough/passthrough.py
+++ b/src/VBox/Additions/common/crOpenGL/passthrough/passthrough.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,30 +11,30 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """#include <stdio.h>
+print("""#include <stdio.h>
 #include "cr_error.h"
 #include "cr_string.h"
 #include "cr_spu.h"
 #include "passthroughspu.h"
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 
-print 'SPUNamedFunctionTable _cr_passthrough_table[%d];' % ( len(keys) + 1 )
+print('SPUNamedFunctionTable _cr_passthrough_table[%d];' % ( len(keys) + 1 ))
 
-print """
-static void __fillin( int offset, char *name, SPUGenericFunction func )
+print("""
+static void __fillin(int offset, char *name, SPUGenericFunction func)
 {
-	_cr_passthrough_table[offset].name = crStrdup( name );
+	_cr_passthrough_table[offset].name = crStrdup(name);
 	_cr_passthrough_table[offset].fn = func;
 }
 
 void BuildPassthroughTable( SPU *child )
-{"""
+{""")
 
 for index in range(len(keys)):
 	func_name = keys[index]
-	print '\t__fillin( %3d, "%s", (SPUGenericFunction) child->dispatch_table.%s );' % (index, func_name, func_name )
-print '\t__fillin( %3d, NULL, NULL );' % len(keys)
-print '}'
+	print('\t__fillin(%3d, "%s", (SPUGenericFunction) child->dispatch_table.%s);' % (index, func_name, func_name ))
+print('\t__fillin(%3d, NULL, NULL);' % len(keys))
+print('}')
diff --git a/src/VBox/Additions/common/crOpenGL/stub_common.py b/src/VBox/Additions/common/crOpenGL/stub_common.py
index d52542b..7d2bbfc 100755
--- a/src/VBox/Additions/common/crOpenGL/stub_common.py
+++ b/src/VBox/Additions/common/crOpenGL/stub_common.py
@@ -3,29 +3,30 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 curver = sys.version_info[0] + sys.version_info[1]/10.0
 if curver < 2.2:
-	print >>sys.stderr, "Your python is version %g.  Chromium requires at least"%(curver)
-	print >>sys.stderr, "version 2.2.  Please upgrade your python installation."
+	print("Your python is version %g.  Chromium requires at least"%(curver), file=sys.stderr)
+	print("version 2.2.  Please upgrade your python installation.", file=sys.stderr)
 	sys.exit(1)
 
 import string;
 import re;
 
 def CopyrightC( ):
-	print """/* Copyright (c) 2001, Stanford University
+	print("""/* Copyright (c) 2001, Stanford University
 	All rights reserved.
 
 	See the file LICENSE.txt for information on redistributing this software. */
-	"""
+	""")
 
 def CopyrightDef( ):
-	print """; Copyright (c) 2001, Stanford University
+	print("""; Copyright (c) 2001, Stanford University
 	; All rights reserved.
 	;
 	; See the file LICENSE.txt for information on redistributing this software.
-	"""
+	""")
 
 def DecoderName( glName ):
 	return "crUnpack" + glName
@@ -100,9 +101,7 @@ def GetAnnotations( filename, key ):
 	except KeyError:
 		return []
 
-	keys = subtable.keys()
-	keys.sort()
-	return keys
+	return sorted(subtable.keys())
 
 def FindAnnotation( filename, key, subkey ):
 	table = {}
@@ -166,9 +165,7 @@ def AllSpecials( table_file ):
 	except KeyError:
 		table = LoadSpecials( filename )
 	
-	keys = table.keys()
-	keys.sort()
-	return keys
+	return sorted(table.keys())
 
 def AllSpecials( table_file ):
 	filename = table_file + "_special"
@@ -179,9 +176,7 @@ def AllSpecials( table_file ):
 	except KeyError:
 		table = LoadSpecials(filename)
 	
-	ret = table.keys()
-	ret.sort()
-	return ret
+	return sorted(table.keys())
 	
 def NumSpecials( table_file ):
 	filename = table_file + "_special"
diff --git a/src/VBox/Additions/common/crOpenGL/tsfuncs.py b/src/VBox/Additions/common/crOpenGL/tsfuncs.py
old mode 100644
new mode 100755
index 0b4f78f..020b5cc
--- a/src/VBox/Additions/common/crOpenGL/tsfuncs.py
+++ b/src/VBox/Additions/common/crOpenGL/tsfuncs.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,11 +11,11 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE tsfuncs.py SCRIPT */
 
 #include "stub.h"
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -22,25 +23,25 @@ for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
 
-	print "static %s SPULOAD_APIENTRY ts_%s( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params) )
-	print "{"
-	print "\tSPUDispatchTable *tab = (SPUDispatchTable *) crGetTSD(&stub.dispatchTSD);"
+	print("static %s SPULOAD_APIENTRY ts_%s(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params) ))
+	print("{")
+	print("\tSPUDispatchTable *tab = (SPUDispatchTable *) crGetTSD(&stub.dispatchTSD);")
 
 	if return_type != "void":
-		print "\treturn ",
+		print("\treturn ", end=" ")
 
-	print "\ttab->%s( %s );" % (func_name, apiutil.MakeCallString(params))
-	print "}"
-	print ""
+	print("\ttab->%s(%s);" % (func_name, apiutil.MakeCallString(params)))
+	print("}")
+	print("")
 
 
-print "SPUDispatchTable stubThreadsafeDispatch = {"
+print("SPUDispatchTable stubThreadsafeDispatch = {")
 
 for func_name in keys:
-	print "\tts_%s," % func_name
+	print("\tts_%s," % func_name)
 
-print "\tNULL,  /* copyList */"
-print "\tNULL,  /* copy_of */"
-print "\t0,     /* mark */"
-print "\tNULL   /* server */"
-print "};"
+print("\tNULL,  /* copyList */")
+print("\tNULL,  /* copy_of */")
+print("\t0,     /* mark */")
+print("\tNULL   /* server */")
+print("};")
diff --git a/src/VBox/Additions/common/crOpenGL/windows_exports.py b/src/VBox/Additions/common/crOpenGL/windows_exports.py
old mode 100644
new mode 100755
index 0b4270a..6c756b5
--- a/src/VBox/Additions/common/crOpenGL/windows_exports.py
+++ b/src/VBox/Additions/common/crOpenGL/windows_exports.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -13,12 +14,12 @@ def GenerateEntrypoints():
 
 	apiutil.CopyrightC()
 
-	print '#include "chromium.h"'
-	print '#include "stub.h"'
-	print ''
-	print '#define NAKED __declspec(naked)'
-	print '#define UNUSED(x) ((void)(x))'
-	print ''
+	print('#include "chromium.h"')
+	print('#include "stub.h"')
+	print('')
+	print('#define NAKED __declspec(naked)')
+	print('#define UNUSED(x) ((void)(x))')
+	print('')
 
 
 	# Get sorted list of dispatched functions.
@@ -36,18 +37,18 @@ def GenerateEntrypoints():
 		return_type = apiutil.ReturnType(func_name)
 		params = apiutil.Parameters(func_name)
 
-		print "NAKED %s cr_gl%s( %s )" % (return_type, func_name,
-									  apiutil.MakeDeclarationString( params ))
-		print "{"
-		print "\t__asm jmp [glim.%s]" % func_name
+		print("NAKED %s cr_gl%s(%s)" % (return_type, func_name,
+									  apiutil.MakeDeclarationString( params )))
+		print("{")
+		print("\t__asm jmp [glim.%s]" % func_name)
 		for (name, type, vecSize) in params:
-			print "\tUNUSED( %s );" % name
-		print "}"
-		print ""
+			print("\tUNUSED(%s);" % name)
+		print("}")
+		print("")
 
-	print '/*'
-	print '* Aliases'
-	print '*/'
+	print('/*')
+	print('* Aliases')
+	print('*/')
 
 	# Now loop over all the functions and take care of any aliases
 	allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -64,31 +65,31 @@ def GenerateEntrypoints():
 		if alias:
 			return_type = apiutil.ReturnType(func_name)
 			params = apiutil.Parameters(func_name)
-			print "NAKED %s cr_gl%s( %s )" % (return_type, func_name,
-								apiutil.MakeDeclarationString( params ))
-			print "{"
-			print "\t__asm jmp [glim.%s]" % alias
+			print("NAKED %s cr_gl%s(%s)" % (return_type, func_name,
+								apiutil.MakeDeclarationString( params )))
+			print("{")
+			print("\t__asm jmp [glim.%s]" % alias)
 			for (name, type, vecSize) in params:
-				print "\tUNUSED( %s );" % name
-			print "}"
-			print ""
+				print("\tUNUSED(%s);" % name)
+			print("}")
+			print("")
 
 
-	print '/*'
-	print '* No-op stubs'
-	print '*/'
+	print('/*')
+	print('* No-op stubs')
+	print('*/')
 
 	# Now generate no-op stub functions
 	for func_name in allkeys:
 		if "stub" in apiutil.ChromiumProps(func_name):
 			return_type = apiutil.ReturnType(func_name)
 			params = apiutil.Parameters(func_name)
-			print "NAKED %s cr_gl%s( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
-			print "{"
+			print("NAKED %s cr_gl%s(%s)" % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+			print("{")
 			if return_type != "void":
-				print "return (%s) 0" % return_type
-			print "}"
-			print ""
+				print("return (%s) 0" % return_type)
+			print("}")
+			print("")
 
 
 		
diff --git a/src/VBox/Additions/common/crOpenGL/windows_getprocaddress.py b/src/VBox/Additions/common/crOpenGL/windows_getprocaddress.py
old mode 100644
new mode 100755
index 21783b3..e9f668e
--- a/src/VBox/Additions/common/crOpenGL/windows_getprocaddress.py
+++ b/src/VBox/Additions/common/crOpenGL/windows_getprocaddress.py
@@ -3,13 +3,14 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE getprocaddress.py SCRIPT */
 #include "chromium.h"
 #include "cr_string.h"
@@ -23,9 +24,9 @@ print """
 #pragma warning( disable: 4055 )
 #endif
 
-"""
+""")
 
-print """
+print("""
 struct name_address {
   const char *name;
   CR_PROC address;
@@ -34,7 +35,7 @@ struct name_address {
 PROC WINAPI wglGetProcAddress_prox( LPCSTR name );
 
 static struct name_address functions[] = {
-"""
+""")
 
 
 keys = apiutil.GetAllFunctionsAndOmittedAliases(sys.argv[1]+"/APIspec.txt")
@@ -59,13 +60,13 @@ for func_name in keys:
     name = "gl" + func_name
     address = "cr_gl" + proc_name
     if wrap:
-        print '#ifdef CR_%s' % wrap
-    print '\t{ "%s", (CR_PROC) %s },' % (name, address)
+        print('#ifdef CR_%s' % wrap)
+    print('\t{ "%s", (CR_PROC) %s },' % (name, address))
     if wrap:
-        print '#endif'
+        print('#endif')
 
 
-print "\t/* Chromium binding/glue functions */"
+print("\t/* Chromium binding/glue functions */")
 
 for func_name in keys:
     if (func_name == "Writeback" or
@@ -74,9 +75,9 @@ for func_name in keys:
         func_name == "GetAttribsLocations"):
         continue
     if apiutil.Category(func_name) == "Chromium":
-        print '\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name)
+        print('\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name))
 
-print "\t/* Windows ICD functions */"
+print("\t/* Windows ICD functions */")
 
 for func_name in ( "CopyContext",
     "CreateContext",
@@ -94,11 +95,11 @@ for func_name in ( "CopyContext",
     "ReleaseContext",
     "SetContext",
     "ValidateVersion"):
-    print '\t{ "Drv%s", (CR_PROC) Drv%s },' % (func_name, func_name)
+    print('\t{ "Drv%s", (CR_PROC) Drv%s },' % (func_name, func_name))
 
-print '\t{ "DrvGetProcAddress", (CR_PROC) wglGetProcAddress_prox },'
+print('\t{ "DrvGetProcAddress", (CR_PROC) wglGetProcAddress_prox },')
 
-print """
+print("""
     { NULL, NULL }
 };
 
@@ -131,24 +132,24 @@ CR_PROC CR_APIENTRY crGetProcAddress( const char *name )
         }
     }
 
-    if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
-    if (!crStrcmp( name, "wglGetExtensionsStringARB" )) return (CR_PROC) wglGetExtensionsStringARB;
+    if (!crStrcmp(name, "wglGetExtensionsStringEXT")) return (CR_PROC) wglGetExtensionsStringEXT;
+    if (!crStrcmp(name, "wglGetExtensionsStringARB")) return (CR_PROC) wglGetExtensionsStringARB;
 
-    if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
-    if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
-    if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
+    if (!crStrcmp(name, "wglChoosePixelFormatEXT")) return (CR_PROC) wglChoosePixelFormatEXT;
+    if (!crStrcmp(name, "wglGetPixelFormatAttribivEXT")) return (CR_PROC) wglGetPixelFormatAttribivEXT;
+    if (!crStrcmp(name, "wglGetPixelFormatAttribfvEXT")) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
 
-    if (!crStrcmp( name, "wglChoosePixelFormatARB" )) return (CR_PROC) wglChoosePixelFormatEXT;
-    if (!crStrcmp( name, "wglGetPixelFormatAttribivARB" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
-    if (!crStrcmp( name, "wglGetPixelFormatAttribfvARB" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
+    if (!crStrcmp(name, "wglChoosePixelFormatARB")) return (CR_PROC) wglChoosePixelFormatEXT;
+    if (!crStrcmp(name, "wglGetPixelFormatAttribivARB")) return (CR_PROC) wglGetPixelFormatAttribivEXT;
+    if (!crStrcmp(name, "wglGetPixelFormatAttribfvARB")) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
 
-    if (!crStrcmp( name, "wglSwapIntervalEXT" )) return (CR_PROC) wglSwapIntervalEXT;
+    if (!crStrcmp(name, "wglSwapIntervalEXT")) return (CR_PROC) wglSwapIntervalEXT;
     
     crDebug("Returning GetProcAddress:NULL for %s", name);
     return NULL;
 }
 
-"""
+""")
 
 
 
@@ -161,10 +162,10 @@ print_foo = """
         wglChoosePixelFormatFunc_t wglChoosePixelFormatEXT = NULL;
         wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = NULL;
         wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = NULL;
-        if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
-        if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
-        if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
-        if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
+        if (!crStrcmp(name, "wglGetExtensionsStringEXT")) return (CR_PROC) wglGetExtensionsStringEXT;
+        if (!crStrcmp(name, "wglChoosePixelFormatEXT")) return (CR_PROC) wglChoosePixelFormatEXT;
+        if (!crStrcmp(name, "wglGetPixelFormatAttribivEXT")) return (CR_PROC) wglGetPixelFormatAttribivEXT;
+        if (!crStrcmp(name, "wglGetPixelFormatAttribfvEXT")) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
     }
 #endif
 """
diff --git a/src/VBox/Additions/common/crOpenGL/windows_i386_exports.py b/src/VBox/Additions/common/crOpenGL/windows_i386_exports.py
old mode 100644
new mode 100755
index e4d70e5..5a4e744
--- a/src/VBox/Additions/common/crOpenGL/windows_i386_exports.py
+++ b/src/VBox/Additions/common/crOpenGL/windows_i386_exports.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -12,14 +13,14 @@ import apiutil
 def GenerateEntrypoints():
 
 	#apiutil.CopyrightC()
-	print '%include "iprt/asmdefs.mac"'
-	print ""
-	print "%ifdef RT_ARCH_AMD64"
-	print "extern glim"
-	print "%else ; X86"
-	print "extern _glim"
-	print "%endif"
-	print ""
+	print('%include "iprt/asmdefs.mac"')
+	print("")
+	print("%ifdef RT_ARCH_AMD64")
+	print("extern glim")
+	print("%else ; X86")
+	print("extern _glim")
+	print("%endif")
+	print("")
 
 	# Get sorted list of dispatched functions.
 	# The order is very important - it must match cr_opcodes.h
@@ -33,21 +34,21 @@ def GenerateEntrypoints():
 		if apiutil.Category(func_name) == "VBox":
 			continue
 
-		print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-		print "%ifdef RT_ARCH_AMD64"
-		print "\tmov \trax, qword glim+%d" % (8*index)
-		print "\tjmp \t[rax]"
-		print "%else ; X86"
-		print "\tmov \teax, dword _glim+%d" % (4*index)
-		print "\tjmp \t[eax]"
-		print "%endif"
-		print "ENDPROC cr_gl%s" % func_name
-		print ""
+		print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+		print("%ifdef RT_ARCH_AMD64")
+		print("\tmov \trax, qword glim+%d" % (8*index))
+		print("\tjmp \t[rax]")
+		print("%else ; X86")
+		print("\tmov \teax, dword _glim+%d" % (4*index))
+		print("\tjmp \t[eax]")
+		print("%endif")
+		print("ENDPROC cr_gl%s" % func_name)
+		print("")
 
 
-	print ';'
-	print '; Aliases'
-	print ';'
+	print(';')
+	print('; Aliases')
+	print(';')
 
 	# Now loop over all the functions and take care of any aliases
 	allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
@@ -64,30 +65,30 @@ def GenerateEntrypoints():
 		if alias:
 			# this dict lookup should never fail (raise an exception)!
 			index = keys.index(alias)
-			print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-			print "%ifdef RT_ARCH_AMD64"
-			print "\tmov \trax, qword glim+%d" % (8*index)
-			print "\tjmp \t[rax]"
-			print "%else ; X86"
-			print "\tmov \teax, dword _glim+%d" % (4*index)
-			print "\tjmp \t[eax]"
-			print "%endif"
-			print "ENDPROC cr_gl%s" % func_name
-			print ""
-
-
-	print ';'
-	print '; No-op stubs'
-	print ';'
+			print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+			print("%ifdef RT_ARCH_AMD64")
+			print("\tmov \trax, qword glim+%d" % (8*index))
+			print("\tjmp \t[rax]")
+			print("%else ; X86")
+			print("\tmov \teax, dword _glim+%d" % (4*index))
+			print("\tjmp \t[eax]")
+			print("%endif")
+			print("ENDPROC cr_gl%s" % func_name)
+			print("")
+
+
+	print(';')
+	print('; No-op stubs')
+	print(';')
 
 	# Now generate no-op stub functions
 	for func_name in allkeys:
 		if "stub" in apiutil.ChromiumProps(func_name):
-			print "BEGINPROC_EXPORTED cr_gl%s" % func_name
-			print "\tleave"
-			print "\tret"
-			print "ENDPROC cr_gl%s" % func_name
-			print ""
+			print("BEGINPROC_EXPORTED cr_gl%s" % func_name)
+			print("\tleave")
+			print("\tret")
+			print("ENDPROC cr_gl%s" % func_name)
+			print("")
 
 
 GenerateEntrypoints()
diff --git a/src/VBox/Additions/linux/drm/vbox_drv.c b/src/VBox/Additions/linux/drm/vbox_drv.c
index 8a1cba5..91b9de5 100644
--- a/src/VBox/Additions/linux/drm/vbox_drv.c
+++ b/src/VBox/Additions/linux/drm/vbox_drv.c
@@ -241,6 +241,16 @@ static int vbox_master_set(struct drm_device *dev,
      * do not advertise dynamic modes on the first query and send a
      * tentative hotplug notification after that to see if they query again. */
     vbox->initial_mode_queried = false;
+    mutex_lock(&vbox->hw_mutex);
+    /* Disable VBVA when someone releases master in case the next person tries
+     * to do VESA. */
+    /** @todo work out if anyone is likely to and whether it will even work. */
+    /* Update: we also disable it because if the new master does not do dirty
+     * rectangle reporting (e.g. old versions of Plymouth) then at least the
+     * first screen will still be updated.  We enable it as soon as we
+     * receive a dirty rectangle report. */
+    vbox_disable_accel(vbox);
+    mutex_unlock(&vbox->hw_mutex);
     return 0;
 }
 
@@ -254,15 +264,9 @@ static void vbox_master_drop(struct drm_device *dev,
 #endif
 {
     struct vbox_private *vbox = dev->dev_private;
+    /* See vbox_master_set() */
     vbox->initial_mode_queried = false;
     mutex_lock(&vbox->hw_mutex);
-    /* Disable VBVA when someone releases master in case the next person tries
-     * to do VESA. */
-    /** @todo work out if anyone is likely to and whether it will even work. */
-    /* Update: we also disable it because if the new master does not do dirty
-     * rectangle reporting (e.g. old versions of Plymouth) then at least the
-     * first screen will still be updated.  We enable it as soon as we
-     * receive a dirty rectangle report. */
     vbox_disable_accel(vbox);
     mutex_unlock(&vbox->hw_mutex);
 }
@@ -303,8 +307,6 @@ static struct drm_driver driver =
 
 static int __init vbox_init(void)
 {
-    unsigned i;
-
 #ifdef CONFIG_VGA_CONSOLE
     if (vgacon_text_force() && vbox_modeset == -1)
         return -EINVAL;
@@ -313,12 +315,6 @@ static int __init vbox_init(void)
     if (vbox_modeset == 0)
         return -EINVAL;
 
-    /* Do not load if any of the virtual consoles is in graphics mode to be
-     * sure that we do not pick a fight with a user-mode driver or VESA. */
-    for (i = 0; i < MAX_NR_CONSOLES - 1; ++i)
-        if (vc_cons[i].d && vc_cons[i].d->vc_mode == KD_GRAPHICS)
-            return -EINVAL;
-
     return drm_pci_init(&driver, &vbox_pci_driver);
 }
 static void __exit vbox_exit(void)
diff --git a/src/VBox/Additions/linux/drm/vbox_drv.h b/src/VBox/Additions/linux/drm/vbox_drv.h
index c3044ff..f47e11a 100644
--- a/src/VBox/Additions/linux/drm/vbox_drv.h
+++ b/src/VBox/Additions/linux/drm/vbox_drv.h
@@ -214,7 +214,7 @@ extern void vbox_mode_fini(struct drm_device *dev);
 
 void vbox_enable_accel(struct vbox_private *vbox);
 void vbox_disable_accel(struct vbox_private *vbox);
-void vbox_enable_caps(struct vbox_private *vbox);
+void vbox_report_caps(struct vbox_private *vbox);
 
 void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
                                        struct drm_clip_rect *rects,
diff --git a/src/VBox/Additions/linux/drm/vbox_main.c b/src/VBox/Additions/linux/drm/vbox_main.c
index 86562de..b85e091 100644
--- a/src/VBox/Additions/linux/drm/vbox_main.c
+++ b/src/VBox/Additions/linux/drm/vbox_main.c
@@ -92,9 +92,9 @@ void vbox_disable_accel(struct vbox_private *vbox)
         VBoxVBVADisable(&vbox->vbva_info[i], &vbox->submit_info, i);
 }
 
-void vbox_enable_caps(struct vbox_private *vbox)
+void vbox_report_caps(struct vbox_private *vbox)
 {
-    uint32_t caps =   VBVACAPS_DISABLE_CURSOR_INTEGRATION
+    uint32_t caps =    VBVACAPS_DISABLE_CURSOR_INTEGRATION
                      | VBVACAPS_IRQ
                      | VBVACAPS_USE_VBVA_ONLY;
     if (vbox->initial_mode_queried)
diff --git a/src/VBox/Additions/linux/drm/vbox_mode.c b/src/VBox/Additions/linux/drm/vbox_mode.c
index 031c8a5..ad8a717 100644
--- a/src/VBox/Additions/linux/drm/vbox_mode.c
+++ b/src/VBox/Additions/linux/drm/vbox_mode.c
@@ -106,8 +106,6 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
                                 crtc->x * bpp / 8 + crtc->y * pitch,
                                 pitch, width, height,
                                 vbox_crtc->blanked ? 0 : bpp, flags);
-    VBoxHGSMIReportFlagsLocation(&vbox->submit_info,   vbox->vram_map_start
-                                                     + vbox->host_flags_offset);
     LogFunc(("vboxvideo: %d\n", __LINE__));
 }
 
@@ -502,8 +500,20 @@ static int vbox_get_modes(struct drm_connector *connector)
     LogFunc(("vboxvideo: %d: connector=%p\n", __LINE__, connector));
     vbox_connector = to_vbox_connector(connector);
     vbox = connector->dev->dev_private;
+    /* Heuristic: we do not want to tell the host that we support dynamic
+     * resizing unless we feel confident that the user space client using
+     * the video driver can handle hot-plug events.  So the first time modes
+     * are queried after a "master" switch we tell the host that we do not,
+     * and immediately after we send the client a hot-plug notification as
+     * a test to see if they will respond and query again.
+     * That is also the reason why capabilities are reported to the host at
+     * this place in the code rather than elsewhere.
+     * We need to report the flags location before reporting the IRQ
+     * capability. */
+    VBoxHGSMIReportFlagsLocation(&vbox->submit_info,   vbox->vram_map_start
+                                                     + vbox->host_flags_offset);
     if (vbox_connector->vbox_crtc->crtc_id == 0)
-        vbox_enable_caps(vbox);
+        vbox_report_caps(vbox);
     if (!vbox->initial_mode_queried) {
         if (vbox_connector->vbox_crtc->crtc_id == 0) {
             vbox->initial_mode_queried = true;
@@ -720,7 +730,9 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
         return ret;
     if (   caps & VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER
         || !(caps & VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE))
-        return -EINVAL;
+        /* -EINVAL means cursor_set2() not supported, -EAGAIN means
+         * retry at once. */
+        return -EBUSY;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
     obj = drm_gem_object_lookup(file_priv, handle);
diff --git a/src/VBox/Additions/linux/installer/vboxadd-x11.sh b/src/VBox/Additions/linux/installer/vboxadd-x11.sh
index 5638b03..604f63c 100755
--- a/src/VBox/Additions/linux/installer/vboxadd-x11.sh
+++ b/src/VBox/Additions/linux/installer/vboxadd-x11.sh
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Linux Additions X11 setup init script ($Revision: 107150 $)
+# Linux Additions X11 setup init script ($Revision: 110817 $)
 #
 
 #
@@ -380,7 +380,10 @@ setup()
     *)
         if test -f /etc/modprobe.d/blacklist-vboxvideo.conf; then
             rm -f /etc/modprobe.d/blacklist-vboxvideo.conf
-            ${MODPROBE} vboxvideo
+            # We do not want to load the driver if X.Org Server is already
+            # running, as without a driver the server will touch the hardware
+            # directly, causing problems.
+            ps -Af | grep -q '[X]org' || ${MODPROBE} vboxvideo
         fi
         ;;
     esac
diff --git a/src/VBox/Additions/linux/installer/vboxadd.sh b/src/VBox/Additions/linux/installer/vboxadd.sh
index f72e32f..f423d46 100755
--- a/src/VBox/Additions/linux/installer/vboxadd.sh
+++ b/src/VBox/Additions/linux/installer/vboxadd.sh
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Linux Additions kernel module init script ($Revision: 110520 $)
+# Linux Additions kernel module init script ($Revision: 111368 $)
 #
 
 #
@@ -328,6 +328,8 @@ setup_modules()
         show_error "Look at $LOG to find out what went wrong"
     fi
     succ_msg
+    echo "override vboxguest * misc" > /etc/depmod.d/vboxvideo-upstream.conf
+    echo "override vboxsf * misc" > /etc/depmod.d/vboxvideo-upstream.conf
     echo "override vboxvideo * misc" > /etc/depmod.d/vboxvideo-upstream.conf
     depmod
     return 0
diff --git a/src/VBox/Additions/x11/VBoxClient/check3d.cpp b/src/VBox/Additions/x11/VBoxClient/check3d.cpp
index 1e430ff..7b7036c 100644
--- a/src/VBox/Additions/x11/VBoxClient/check3d.cpp
+++ b/src/VBox/Additions/x11/VBoxClient/check3d.cpp
@@ -17,14 +17,20 @@
 
 #include "VBoxClient.h"
 
+#include <VBox/VBoxGuest.h>
 #include <VBox/VBoxGuestLib.h>
+#include <VBox/HostServices/VBoxCrOpenGLSvc.h>
+#include "../../common/VBoxGuestLib/VBGLR3Internal.h" /* HACK ALERT! Using vbglR3DoIOCtl directly!! */
 
 #include <stdlib.h>
 
+#define CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT 0x00000020
+
 static int run(struct VBCLSERVICE **ppInterface, bool fDaemonised)
 {
     int rc;
     HGCMCLIENTID cClientID;
+    CRVBOXHGCMGETCAPS caps;
     LogFlowFunc(("\n"));
 
     NOREF(ppInterface);
@@ -36,6 +42,19 @@ static int run(struct VBCLSERVICE **ppInterface, bool fDaemonised)
     rc = VbglR3HGCMConnect("VBoxSharedCrOpenGL", &cClientID);
     if (RT_FAILURE(rc))
         exit(1);
+    caps.hdr.result      = VERR_WRONG_ORDER;
+    caps.hdr.u32ClientID = cClientID;
+    caps.hdr.u32Function = SHCRGL_GUEST_FN_GET_CAPS_LEGACY;
+    caps.hdr.cParms      = SHCRGL_CPARMS_GET_CAPS_LEGACY;
+
+    caps.Caps.type       = VMMDevHGCMParmType_32bit;
+    caps.Caps.u.value32  = 0;
+
+    rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(caps)), &caps, sizeof(caps));
+    if (RT_FAILURE(rc))
+        exit(1);
+    if (caps.Caps.u.value32 & CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT)
+        exit(1);
     VbglR3HGCMDisconnect(cClientID);
     VbglR3Term();
     LogFlowFunc(("returning %Rrc\n", rc));
diff --git a/src/VBox/Additions/x11/vboxvideo/vboxvideo.c b/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
index 8dce926..77cf20f 100644
--- a/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
+++ b/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
@@ -746,6 +746,13 @@ VBOXPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
         close(drmFd);
         return FALSE;
     }
+    /* It is safe to call this, as the X server enables I/O access before
+     * calling the probe call-backs. */
+    if (!xf86EnableIO())
+    {
+        xf86Msg(X_INFO, "vboxvideo: this driver requires direct hardware access.  You may wish to use the kernel driver instead.\n");
+        return FALSE;
+    }
     pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, VBOXPCIchipsets,
                                 NULL, NULL, NULL, NULL, NULL);
     if (pScrn != NULL) {
diff --git a/src/VBox/Devices/Audio/AudioMixBuffer.cpp b/src/VBox/Devices/Audio/AudioMixBuffer.cpp
index 998447c..acab3f4 100644
--- a/src/VBox/Devices/Audio/AudioMixBuffer.cpp
+++ b/src/VBox/Devices/Audio/AudioMixBuffer.cpp
@@ -1117,7 +1117,7 @@ static int audioMixBufMixTo(PPDMAUDIOMIXBUF pDst, PPDMAUDIOMIXBUF pSrc, uint32_t
 
     AUDMIXBUF_LOG(("cReadTotal=%RU32 (pcProcessed), cWrittenTotal=%RU32, cSrcMixed=%RU32, cDstUsed=%RU32, rc=%Rrc\n",
                    cReadTotal, cWrittenTotal, pSrc->cMixed, pDst->cUsed, rc));
-    return VINF_SUCCESS;
+    return rc;
 }
 
 /**
diff --git a/src/VBox/Devices/Audio/AudioMixer.cpp b/src/VBox/Devices/Audio/AudioMixer.cpp
index f3474b9..e0473ca 100644
--- a/src/VBox/Devices/Audio/AudioMixer.cpp
+++ b/src/VBox/Devices/Audio/AudioMixer.cpp
@@ -57,6 +57,7 @@ static int audioMixerSinkRemoveStreamInternal(PAUDMIXSINK pSink, PAUDMIXSTREAM p
 static void audioMixerSinkReset(PAUDMIXSINK pSink);
 static int audioMixerSinkUpdateInternal(PAUDMIXSINK pSink);
 
+int audioMixerStreamCtlInternal(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl);
 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pStream);
 
 
@@ -474,16 +475,26 @@ int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream)
     {
         /** @todo Check if stream already is assigned to (another) sink. */
 
-        /* Apply the sink's combined volume to the stream. */
-        AssertPtr(pStream->pConn);
-        rc = pStream->pConn->pfnStreamSetVolume(pStream->pConn, pStream->pStream, &pSink->VolumeCombined);
+        /* If the sink is running, make sure that the added stream also is enabled. */
+        if (pSink->fStatus & AUDMIXSINK_STS_RUNNING)
+            rc = audioMixerStreamCtlInternal(pStream, PDMAUDIOSTREAMCMD_ENABLE, AUDMIXSTRMCTL_FLAG_NONE);
 
-        /* Save pointer to sink the stream is attached to. */
-        pStream->pSink = pSink;
+        if (RT_SUCCESS(rc))
+        {
+            /* Apply the sink's combined volume to the stream. */
+            rc = pStream->pConn->pfnStreamSetVolume(pStream->pConn, pStream->pStream, &pSink->VolumeCombined);
+            AssertRC(rc);
+        }
+
+        if (RT_SUCCESS(rc))
+        {
+            /* Save pointer to sink the stream is attached to. */
+            pStream->pSink = pSink;
 
-        /* Append stream to sink's list. */
-        RTListAppend(&pSink->lstStreams, &pStream->Node);
-        pSink->cStreams++;
+            /* Append stream to sink's list. */
+            RTListAppend(&pSink->lstStreams, &pStream->Node);
+            pSink->cStreams++;
+        }
     }
 
     LogFlowFunc(("[%s]: cStreams=%RU8, rc=%Rrc\n", pSink->pszName, pSink->cStreams, rc));
@@ -643,7 +654,7 @@ int AudioMixerSinkCtl(PAUDMIXSINK pSink, AUDMIXSINKCMD enmSinkCmd)
     PAUDMIXSTREAM pStream;
     RTListForEach(&pSink->lstStreams, pStream, AUDMIXSTREAM, Node)
     {
-        int rc2 = AudioMixerStreamCtl(pStream, enmCmdStream, AUDMIXSTRMCTL_FLAG_NONE);
+        int rc2 = audioMixerStreamCtlInternal(pStream, enmCmdStream, AUDMIXSTRMCTL_FLAG_NONE);
         if (RT_SUCCESS(rc))
             rc = rc2;
         /* Keep going. Flag? */
@@ -660,12 +671,12 @@ int AudioMixerSinkCtl(PAUDMIXSINK pSink, AUDMIXSINKCMD enmSinkCmd)
         pSink->fStatus |= AUDMIXSINK_STS_PENDING_DISABLE;
     }
 
+    LogFlowFunc(("[%s]: enmCmd=%d, fStatus=0x%x, rc=%Rrc\n", pSink->pszName, enmSinkCmd, pSink->fStatus, rc));
+
     /* Not running anymore? Reset. */
     if (!(pSink->fStatus & AUDMIXSINK_STS_RUNNING))
         audioMixerSinkReset(pSink);
 
-    LogFlowFunc(("[%s]: enmCmd=%d, fStatus=0x%x, rc=%Rrc\n", pSink->pszName, enmSinkCmd, pSink->fStatus, rc));
-
     int rc2 = RTCritSectLeave(&pSink->CritSect);
     AssertRC(rc2);
 
@@ -995,7 +1006,10 @@ int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t
         cbRead = RT_MAX(cbRead, cbTotalRead);
 
         PDMAUDIOSTRMSTS strmSts = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream);
-        fClean &= !(strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE);
+
+        /* Still some data available? Then sink is not clean (yet). */
+        if (strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE)
+            fClean = false;
     }
 
     if (RT_SUCCESS(rc))
@@ -1017,7 +1031,7 @@ int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t
     RTMemFree(pvMixBuf);
 #endif
 
-    Log3Func(("[%s] cbRead=%RU32, fStatus=0x%x, rc=%Rrc\n", pSink->pszName, cbRead, pSink->fStatus, rc));
+    Log3Func(("[%s] cbRead=%RU32, fClean=%RTbool, fStatus=0x%x, rc=%Rrc\n", pSink->pszName, cbRead, fClean, pSink->fStatus, rc));
 
     int rc2 = RTCritSectLeave(&pSink->CritSect);
     AssertRC(rc2);
@@ -1110,7 +1124,7 @@ static void audioMixerSinkReset(PAUDMIXSINK pSink)
     if (!pSink)
         return;
 
-    LogFunc(("%s\n", pSink->pszName));
+    LogFunc(("[%s]\n", pSink->pszName));
 
     if (pSink->enmDir == AUDMIXSINKDIR_INPUT)
     {
@@ -1289,14 +1303,14 @@ static int audioMixerSinkUpdateInternal(PAUDMIXSINK pSink)
         PPDMIAUDIOCONNECTOR pConn = pMixStream->pConn;
         AssertPtr(pConn);
 
-        uint32_t cCaptured = 0;
+        uint32_t cProc = 0;
 
         int rc2 = pConn->pfnStreamIterate(pConn, pStream);
         if (RT_SUCCESS(rc2))
         {
             if (pSink->enmDir == AUDMIXSINKDIR_INPUT)
             {
-                rc = pConn->pfnStreamCapture(pConn, pMixStream->pStream, &cCaptured);
+                rc = pConn->pfnStreamCapture(pConn, pStream, &cProc);
                 if (RT_FAILURE(rc2))
                 {
                     LogFlowFunc(("%s: Failed capturing stream '%s', rc=%Rrc\n", pSink->pszName, pMixStream->pStream->szName, rc2));
@@ -1305,12 +1319,12 @@ static int audioMixerSinkUpdateInternal(PAUDMIXSINK pSink)
                     continue;
                 }
 
-                if (cCaptured)
+                if (cProc)
                     pSink->fStatus |= AUDMIXSINK_STS_DIRTY;
             }
             else if (pSink->enmDir == AUDMIXSINKDIR_OUTPUT)
             {
-                rc2 = pConn->pfnStreamPlay(pConn, pMixStream->pStream, NULL /* cPlayed */);
+                rc2 = pConn->pfnStreamPlay(pConn, pStream, &cProc);
                 if (RT_FAILURE(rc2))
                 {
                     LogFlowFunc(("%s: Failed playing stream '%s', rc=%Rrc\n", pSink->pszName, pMixStream->pStream->szName, rc2));
@@ -1371,9 +1385,15 @@ static int audioMixerSinkUpdateInternal(PAUDMIXSINK pSink)
             }
         }
 
-        Log3Func(("\t%s: cCaptured=%RU32\n", pMixStream->pStream->szName, cCaptured));
+        Log3Func(("\t%s: cProc=%RU32, rc2=%Rrc\n", pStream->szName, cProc, rc2));
     }
 
+    Log3Func(("[%s] fPendingDisable=%RTbool, %RU8/%RU8 streams disabled\n",
+              RT_BOOL(pSink->fStatus & AUDMIXSINK_STS_PENDING_DISABLE), pSink->pszName, cStreamsDisabled, pSink->cStreams));
+
+    /* Update last updated timestamp. */
+    pSink->tsLastUpdatedMS = RTTimeMilliTS();
+
     /* All streams disabled and the sink is in pending disable mode? */
     if (   cStreamsDisabled == pSink->cStreams
         && (pSink->fStatus & AUDMIXSINK_STS_PENDING_DISABLE))
@@ -1381,9 +1401,6 @@ static int audioMixerSinkUpdateInternal(PAUDMIXSINK pSink)
         audioMixerSinkReset(pSink);
     }
 
-    /* Update last updated timestamp. */
-    pSink->tsLastUpdatedMS = RTTimeMilliTS();
-
     Log3Func(("[%s] cbReadable=%RU32, cbWritable=%RU32, rc=%Rrc\n",
               pSink->pszName, pSink->In.cbReadable, pSink->Out.cbWritable, rc));
 
@@ -1433,9 +1450,9 @@ static int audioMixerSinkUpdateVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME p
     AssertPtrReturn(pSink,      VERR_INVALID_POINTER);
     AssertPtrReturn(pVolMaster, VERR_INVALID_POINTER);
 
-    LogFlowFunc(("[%s]: Master fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n",
+    LogFlowFunc(("[%s] Master fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n",
                   pSink->pszName, pVolMaster->fMuted, pVolMaster->uLeft, pVolMaster->uRight));
-    LogFlowFunc(("[%s]: fMuted=%RTbool, lVol=%RU32, rVol=%RU32 ",
+    LogFlowFunc(("[%s] fMuted=%RTbool, lVol=%RU32, rVol=%RU32 ",
                   pSink->pszName, pSink->Volume.fMuted, pSink->Volume.uLeft, pSink->Volume.uRight));
 
     /** @todo Very crude implementation for now -- needs more work! */
@@ -1492,7 +1509,7 @@ int AudioMixerSinkWrite(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, ui
     AssertMsg(pSink->enmDir == AUDMIXSINKDIR_OUTPUT,
               ("Can't write to a sink which is not an output sink\n"));
 
-    LogFlowFunc(("%s: enmOp=%d, cbBuf=%RU32\n", pSink->pszName, enmOp, cbBuf));
+    Log3Func(("[%s] enmOp=%d, cbBuf=%RU32\n", pSink->pszName, enmOp, cbBuf));
 
     uint32_t cbProcessed;
 
@@ -1501,18 +1518,18 @@ int AudioMixerSinkWrite(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, ui
     {
         if (!(pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream) & PDMAUDIOSTRMSTS_FLAG_ENABLED))
         {
-            LogFlowFunc(("%s: Stream '%s' Disabled, skipping ...\n", pMixStream->pszName, pMixStream->pStream->szName));
+            Log3Func(("\t%s: Stream '%s' disabled, skipping ...\n", pMixStream->pszName, pMixStream->pStream->szName));
             continue;
         }
 
         int rc2 = pMixStream->pConn->pfnStreamWrite(pMixStream->pConn, pMixStream->pStream, pvBuf, cbBuf, &cbProcessed);
         if (RT_FAILURE(rc2))
-            LogFlowFunc(("%s: Failed writing to stream '%s': %Rrc\n", pSink->pszName, pMixStream->pStream->szName, rc2));
+            LogFlowFunc(("[%s] Failed writing to stream '%s': %Rrc\n", pSink->pszName, pMixStream->pStream->szName, rc2));
 
         if (cbProcessed < cbBuf)
         {
-            LogFlowFunc(("%s: Only written %RU32/%RU32 bytes for stream '%s'\n",
-                         pSink->pszName, cbProcessed, cbBuf, pMixStream->pStream->szName));
+            Log3Func(("[%s] Only written %RU32/%RU32 bytes for stream '%s'\n",
+                      pSink->pszName, cbProcessed, cbBuf, pMixStream->pStream->szName));
         }
     }
 
@@ -1536,6 +1553,28 @@ int AudioMixerSinkWrite(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, ui
  ********************************************************************************************************************************/
 
 /**
+ * Controls a mixer stream, internal version.
+ *
+ * @returns IPRT status code.
+ * @param   pMixStream          Mixer stream to control.
+ * @param   enmCmd              Mixer stream command to use.
+ * @param   fCtl                Additional control flags. Pass 0.
+ */
+int audioMixerStreamCtlInternal(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl)
+{
+    AssertPtr(pMixStream->pConn);
+    AssertPtr(pMixStream->pStream);
+
+    RT_NOREF(fCtl);
+
+    int rc = pMixStream->pConn->pfnStreamControl(pMixStream->pConn, pMixStream->pStream, enmCmd);
+
+    LogFlowFunc(("[%s] enmCmd=%ld, rc=%Rrc\n", pMixStream->pszName, enmCmd, rc));
+
+    return rc;
+}
+
+/**
  * Controls a mixer stream.
  *
  * @returns IPRT status code.
@@ -1553,15 +1592,11 @@ int AudioMixerStreamCtl(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint
     if (RT_FAILURE(rc))
         return rc;
 
-    AssertPtr(pMixStream->pConn);
-    AssertPtr(pMixStream->pStream);
-
-    rc = pMixStream->pConn->pfnStreamControl(pMixStream->pConn, pMixStream->pStream, enmCmd);
-
-    LogFlowFunc(("[%s] enmCmd=%ld, rc=%Rrc\n", pMixStream->pszName, enmCmd, rc));
+    rc = audioMixerStreamCtlInternal(pMixStream, enmCmd, fCtl);
 
     int rc2 = RTCritSectLeave(&pMixStream->CritSect);
-    AssertRC(rc2);
+    if (RT_SUCCESS(rc))
+        rc = rc2;
 
     return rc;
 }
diff --git a/src/VBox/Devices/Audio/DevIchAc97.cpp b/src/VBox/Devices/Audio/DevIchAc97.cpp
index ff8db5c..cedaa62 100644
--- a/src/VBox/Devices/Audio/DevIchAc97.cpp
+++ b/src/VBox/Devices/Audio/DevIchAc97.cpp
@@ -83,8 +83,8 @@
 #define AC97_CR_VALID_MASK (RT_BIT(5) - 1)
 #define AC97_CR_DONT_CLEAR_MASK (AC97_CR_IOCE | AC97_CR_FEIE | AC97_CR_LVBIE)
 
-#define AC97_GC_WR    4              /* rw */
-#define AC97_GC_CR    2              /* rw */
+#define AC97_GC_WR    4                 /* rw    Warm reset. */
+#define AC97_GC_CR    2                 /* rw    Cold reset. */
 #define AC97_GC_VALID_MASK (RT_BIT(6) - 1)
 
 #define AC97_GS_MD3   RT_BIT(17)        /* rw */
@@ -281,7 +281,7 @@ typedef struct AC97BMREGS
 } AC97BMREGS, *PAC97BMREGS;
 
 /**
- * Internal state of an AC97 stream.
+ * Internal state of an AC'97 stream.
  */
 typedef struct AC97STREAMSTATE
 {
@@ -295,15 +295,14 @@ typedef struct AC97STREAMSTATE
 } AC97STREAMSTATE, *PAC97STREAMSTATE;
 
 /**
- * Structure for keeping an AC97 stream state.
- *
- * Contains only register values which do *not* change until a
- * stream reset occurs.
+ * Structure for keeping an AC'97 stream state.
  */
 typedef struct AC97STREAM
 {
     /** Stream number (SDn). */
     uint8_t         u8Strm;
+    /** Criticial section for this stream. */
+    RTCRITSECT      CritSect;
     /** Bus master registers of this stream. */
     AC97BMREGS      Regs;
     /** Internal state of this stream. */
@@ -377,6 +376,8 @@ typedef struct AC97STATE
 #ifndef VBOX_WITH_AUDIO_CALLBACKS
     /** The timer for pumping data thru the attached LUN drivers. */
     PTMTIMERR3              pTimer;
+    /** Criticial section for timer. */
+    RTCRITSECT              csTimer;
 # if HC_ARCH_BITS == 32
     uint32_t                Padding0;
 # endif
@@ -400,7 +401,7 @@ typedef struct AC97STATE
     /** The device's software mixer. */
     R3PTRTYPE(PAUDIOMIXER)  pMixer;
     /** Audio sink for PCM output. */
-    R3PTRTYPE(PAUDMIXSINK)  pSinkOutput;
+    R3PTRTYPE(PAUDMIXSINK)  pSinkOut;
     /** Audio sink for line input. */
     R3PTRTYPE(PAUDMIXSINK)  pSinkLineIn;
     /** Audio sink for microphone input. */
@@ -426,7 +427,11 @@ AssertCompileMemberAlignment(AC97STATE, StatBytesWritten, 8);
 static void ichac97DestroyIn(PAC97STATE pThis, PDMAUDIORECSOURCE enmRecSource);
 static void ichac97DestroyOut(PAC97STATE pThis);
 DECLINLINE(PAC97STREAM) ichac97GetStreamFromID(PAC97STATE pThis, uint32_t uID);
-static int ichac97StreamInit(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm);
+static int ichac97StreamInit(PAC97STREAM pStream, uint8_t u8Strm);
+static void ichac97StreamDestroy(PAC97STREAM pStream);
+static int ichac97StreamOpen(PAC97STATE pThis, PAC97STREAM pStream);
+static int ichac97StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream);
+static void ichac97StreamClose(PAC97STREAM pStream);
 static DECLCALLBACK(void) ichac97Reset(PPDMDEVINS pDevIns);
 #ifndef VBOX_WITH_AUDIO_CALLBACKS
 static void ichac97TimerMaybeStart(PAC97STATE pThis);
@@ -452,7 +457,7 @@ DECLINLINE(PAUDMIXSINK) ichac97IndexToSink(PAC97STATE pThis, uint8_t uIndex)
     switch (uIndex)
     {
         case AC97SOUNDSOURCE_PI_INDEX: return pThis->pSinkLineIn; break;
-        case AC97SOUNDSOURCE_PO_INDEX: return pThis->pSinkOutput; break;
+        case AC97SOUNDSOURCE_PO_INDEX: return pThis->pSinkOut;    break;
         case AC97SOUNDSOURCE_MC_INDEX: return pThis->pSinkMicIn;  break;
         default:       break;
     }
@@ -487,7 +492,7 @@ static void ichac97StreamFetchBDLE(PAC97STATE pThis, PAC97STREAM pStream)
 /**
  * Update the BM status register
  */
-static void ichac97StreamUpdateStatus(PAC97STATE pThis, PAC97STREAM pStream, uint32_t new_sr)
+static void ichac97StreamUpdateSR(PAC97STATE pThis, PAC97STREAM pStream, uint32_t new_sr)
 {
     PPDMDEVINS  pDevIns = ICHAC97STATE_2_DEVINS(pThis);
     PAC97BMREGS pRegs   = &pStream->Regs;
@@ -537,46 +542,68 @@ static void ichac97StreamUpdateStatus(PAC97STATE pThis, PAC97STREAM pStream, uin
     }
 }
 
-static bool ichac97StreamIsActive(PAC97STATE pThis, PAC97STREAM pStream)
+/**
+ * Returns whether an AC'97 stream is enabled or not.
+ *
+ * @returns IPRT status code.
+ * @param   pThis               AC'97 device state.
+ * @param   pStream             Stream to return status for.
+ */
+static bool ichac97StreamIsEnabled(PAC97STATE pThis, PAC97STREAM pStream)
 {
     AssertPtrReturn(pThis,   false);
     AssertPtrReturn(pStream, false);
 
     PAUDMIXSINK pSink = ichac97IndexToSink(pThis, pStream->u8Strm);
-    bool fActive = RT_BOOL(AudioMixerSinkGetStatus(pSink) & AUDMIXSINK_STS_RUNNING);
+    bool fIsEnabled = RT_BOOL(AudioMixerSinkGetStatus(pSink) & AUDMIXSINK_STS_RUNNING);
 
-    LogFlowFunc(("[SD%RU8] fActive=%RTbool\n", pStream->u8Strm, fActive));
-    return fActive;
+    LogFunc(("[SD%RU8] fIsEnabled=%RTbool\n", pStream->u8Strm, fIsEnabled));
+    return fIsEnabled;
 }
 
-static int ichac97StreamSetActive(PAC97STATE pThis, PAC97STREAM pStream, bool fActive)
+static int ichac97StreamEnable(PAC97STATE pThis, PAC97STREAM pStream, bool fEnable)
 {
     AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
 
-    if (!fActive)
+    PAUDMIXSINK pSink = ichac97IndexToSink(pThis, pStream->u8Strm);
+    AssertPtr(pSink);
+
+    const bool fIsEnabled = AudioMixerSinkGetStatus(pSink) & AUDMIXSINK_STS_RUNNING;
+
+    LogFunc(("[SD%RU8] fEnable=%RTbool, fIsEnabled=%RTbool, DCH=%RTbool, cStreamsActive=%RU8\n",
+             pStream->u8Strm, fEnable, fIsEnabled, RT_BOOL(pStream->Regs.sr & AC97_SR_DCH), pThis->cStreamsActive));
+
+    int rc = VINF_SUCCESS;
+
+    if (fEnable != fIsEnabled)
     {
-        if (pThis->cStreamsActive) /* Disable can be called mupltiple times. */
-            pThis->cStreamsActive--;
+        rc = ichac97StreamReOpen(pThis, pStream);
+        if (RT_SUCCESS(rc))
+            rc = AudioMixerSinkCtl(ichac97IndexToSink(pThis, pStream->u8Strm),
+                                   fEnable ? AUDMIXSINKCMD_ENABLE : AUDMIXSINKCMD_DISABLE);
+        if (RT_SUCCESS(rc))
+        {
+            if (!fEnable)
+            {
+                if (pThis->cStreamsActive) /* Disable can be called mupltiple times. */
+                    pThis->cStreamsActive--;
 
 #ifndef VBOX_WITH_AUDIO_CALLBACKS
-        ichac97TimerMaybeStop(pThis);
+                ichac97TimerMaybeStop(pThis);
 #endif
-    }
-    else
-    {
-        pThis->cStreamsActive++;
+            }
+            else
+            {
+                pThis->cStreamsActive++;
 #ifndef VBOX_WITH_AUDIO_CALLBACKS
-        ichac97TimerMaybeStart(pThis);
+                ichac97TimerMaybeStart(pThis);
 #endif
+            }
+        }
     }
 
-    int rc = AudioMixerSinkCtl(ichac97IndexToSink(pThis, pStream->u8Strm),
-                               fActive ? AUDMIXSINKCMD_ENABLE : AUDMIXSINKCMD_DISABLE);
-
-    LogFlowFunc(("[SD%RU8] fActive=%RTbool, cStreamsActive=%RU8, rc=%Rrc\n",
-                 pStream->u8Strm, fActive, pThis->cStreamsActive, rc));
-
+    LogFunc(("Returning %Rrc\n", rc));
     return rc;
 }
 
@@ -585,7 +612,7 @@ static void ichac97StreamResetBMRegs(PAC97STATE pThis, PAC97STREAM pStream)
     AssertPtrReturnVoid(pThis);
     AssertPtrReturnVoid(pStream);
 
-    LogFlowFunc(("[SD%RU8]\n", pStream->u8Strm));
+    LogFunc(("[SD%RU8]\n", pStream->u8Strm));
 
     PAC97BMREGS pRegs = &pStream->Regs;
 
@@ -593,18 +620,40 @@ static void ichac97StreamResetBMRegs(PAC97STATE pThis, PAC97STREAM pStream)
     pRegs->civ      = 0;
     pRegs->lvi      = 0;
 
-    ichac97StreamUpdateStatus(pThis, pStream, AC97_SR_DCH); /** @todo Do we need to do that? */
+    ichac97StreamEnable(pThis, pStream, false /* fActive */);
+
+    ichac97StreamUpdateSR(pThis, pStream, AC97_SR_DCH); /** @todo Do we need to do that? */
 
     pRegs->picb     = 0;
     pRegs->piv      = 0;
     pRegs->cr       = pRegs->cr & AC97_CR_DONT_CLEAR_MASK;
     pRegs->bd_valid = 0;
 
-    ichac97StreamSetActive(pThis, pStream, false /* fActive */);
-
     RT_ZERO(pThis->silence);
 }
 
+static int ichac97StreamInit(PAC97STREAM pStream, uint8_t u8Strm)
+{
+    AssertPtrReturn(pStream, VERR_INVALID_PARAMETER);
+
+    LogFunc(("[SD%RU8] pStream=%p\n", u8Strm, pStream));
+
+    int rc = VINF_SUCCESS;
+
+    pStream->u8Strm         = u8Strm;
+    pStream->State.cbFIFOW  = _4K; /** @todo Make FIFOW size configurable. */
+    pStream->State.offFIFOW = 0;
+    pStream->State.au8FIFOW = (uint8_t *)RTMemAllocZ(pStream->State.cbFIFOW);
+    if (pStream->State.au8FIFOW)
+    {
+        rc = RTCritSectInit(&pStream->CritSect);
+    }
+    else
+        rc = VERR_NO_MEMORY;
+
+    return rc;
+}
+
 static void ichac97StreamDestroy(PAC97STREAM pStream)
 {
     LogFlowFunc(("[SD%RU8]\n", pStream->u8Strm));
@@ -618,6 +667,33 @@ static void ichac97StreamDestroy(PAC97STREAM pStream)
 
     pStream->State.cbFIFOW  = 0;
     pStream->State.offFIFOW = 0;
+
+    if (RTCritSectIsInitialized(&pStream->CritSect))
+        RTCritSectDelete(&pStream->CritSect);
+}
+
+static int ichac97StreamsInit(PAC97STATE pThis)
+{
+    LogFlowFuncEnter();
+
+    int rc = ichac97StreamInit    (&pThis->StreamLineIn, AC97SOUNDSOURCE_PI_INDEX);
+    if (RT_SUCCESS(rc))
+        rc = ichac97StreamInit    (&pThis->StreamMicIn,  AC97SOUNDSOURCE_MC_INDEX);
+        if (RT_SUCCESS(rc))
+            rc = ichac97StreamInit(&pThis->StreamOut,    AC97SOUNDSOURCE_PO_INDEX);
+
+    /* Open all streams with the current AC'97 mixer settings. */
+    if (RT_SUCCESS(rc))
+    {
+        rc = ichac97StreamOpen        (pThis, &pThis->StreamLineIn);
+        if (RT_SUCCESS(rc))
+            rc = ichac97StreamOpen    (pThis, &pThis->StreamMicIn);
+            if (RT_SUCCESS(rc))
+                rc = ichac97StreamOpen(pThis, &pThis->StreamOut);
+    }
+
+    LogFlowFunc(("Returning %Rrc\n", rc));
+    return rc;
 }
 
 static void ichac97StreamsDestroy(PAC97STATE pThis)
@@ -633,17 +709,6 @@ static void ichac97StreamsDestroy(PAC97STATE pThis)
     ichac97StreamDestroy(&pThis->StreamOut);
 }
 
-static int ichac97StreamsInit(PAC97STATE pThis)
-{
-    LogFlowFuncEnter();
-
-    ichac97StreamInit(pThis, &pThis->StreamLineIn, AC97SOUNDSOURCE_PI_INDEX);
-    ichac97StreamInit(pThis, &pThis->StreamMicIn,  AC97SOUNDSOURCE_MC_INDEX);
-    ichac97StreamInit(pThis, &pThis->StreamOut,    AC97SOUNDSOURCE_PO_INDEX);
-
-    return VINF_SUCCESS;
-}
-
 static void ichac97MixerSet(PAC97STATE pThis, uint8_t uMixerIdx, uint16_t uVal)
 {
     if (size_t(uMixerIdx + 2) > sizeof(pThis->mixer_data))
@@ -720,7 +785,7 @@ static void ichac97DestroyOut(PAC97STATE pThis)
     {
         if (pDrv->Out.pMixStrm)
         {
-            AudioMixerSinkRemoveStream(pThis->pSinkOutput, pDrv->Out.pMixStrm);
+            AudioMixerSinkRemoveStream(pThis->pSinkOut, pDrv->Out.pMixStrm);
             AudioMixerStreamDestroy(pDrv->Out.pMixStrm);
 
             pDrv->Out.pMixStrm = NULL;
@@ -799,11 +864,13 @@ static int ichac97CreateOut(PAC97STATE pThis, const char *pszName, PPDMAUDIOSTRE
     AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     AssertPtrReturn(pCfg,    VERR_INVALID_POINTER);
 
+    LogFunc(("%s\n", pszName));
+
     /* Update the sink's format. */
     PDMAUDIOPCMPROPS PCMProps;
     int rc = DrvAudioHlpStreamCfgToProps(pCfg, &PCMProps);
     if (RT_SUCCESS(rc))
-        rc = AudioMixerSinkSetFormat(pThis->pSinkOutput, &PCMProps);
+        rc = AudioMixerSinkSetFormat(pThis->pSinkOut, &PCMProps);
 
     if (RT_FAILURE(rc))
         return rc;
@@ -818,15 +885,15 @@ static int ichac97CreateOut(PAC97STATE pThis, const char *pszName, PPDMAUDIOSTRE
             break;
         }
 
-        AudioMixerSinkRemoveStream(pThis->pSinkOutput, pDrv->Out.pMixStrm);
+        AudioMixerSinkRemoveStream(pThis->pSinkOut, pDrv->Out.pMixStrm);
 
         AudioMixerStreamDestroy(pDrv->Out.pMixStrm);
         pDrv->Out.pMixStrm = NULL;
 
-        int rc2 = AudioMixerSinkCreateStream(pThis->pSinkOutput, pDrv->pConnector, pCfg, 0 /* fFlags */, &pDrv->Out.pMixStrm);
+        int rc2 = AudioMixerSinkCreateStream(pThis->pSinkOut, pDrv->pConnector, pCfg, 0 /* fFlags */, &pDrv->Out.pMixStrm);
         if (RT_SUCCESS(rc2))
         {
-            rc2 = AudioMixerSinkAddStream(pThis->pSinkOutput, pDrv->Out.pMixStrm);
+            rc2 = AudioMixerSinkAddStream(pThis->pSinkOut, pDrv->Out.pMixStrm);
             LogFlowFunc(("LUN#%RU8: Created output \"%s\", rc=%Rrc\n", pDrv->uLUN, pCfg->szName, rc2));
         }
 
@@ -838,17 +905,21 @@ static int ichac97CreateOut(PAC97STATE pThis, const char *pszName, PPDMAUDIOSTRE
     return rc;
 }
 
-static int ichac97StreamInitEx(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm, PPDMAUDIOSTREAMCFG pCfg)
+/**
+ * Opens an AC'97 stream, extended version.
+ *
+ * @returns IPRT status code.
+ * @param   pThis               AC'97 device state.
+ * @param   pStream             Stream to initialize.
+ * @param   pCfg                Audio stream configuration to initialize the stream with.
+ */
+static int ichac97StreamOpenEx(PAC97STATE pThis, PAC97STREAM pStream, PPDMAUDIOSTREAMCFG pCfg)
 {
     AssertPtrReturn(pThis,             VERR_INVALID_POINTER);
     AssertPtrReturn(pStream,           VERR_INVALID_POINTER);
-    AssertReturn(u8Strm <= AC97SOUNDSOURCE_LAST_INDEX, VERR_INVALID_PARAMETER);
     AssertPtrReturn(pCfg,              VERR_INVALID_POINTER);
 
-    pStream->u8Strm = u8Strm;
-
-    LogFlowFunc(("u8Strm=%RU8, %RU32Hz, %RU8 %s\n",
-                 pStream->u8Strm, pCfg->uHz, pCfg->cChannels, pCfg->cChannels > 1 ? "Channels" : "Channel"));
+    LogFunc(("[SD%RU8] pCfg=%p\n", pStream->u8Strm, pCfg));
 
     int rc;
     switch (pStream->u8Strm)
@@ -866,7 +937,7 @@ static int ichac97StreamInitEx(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8
             break;
 
         default:
-            rc = VERR_NOT_SUPPORTED;
+            AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
             break;
     }
 
@@ -877,14 +948,25 @@ static int ichac97StreamInitEx(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8
     return rc;
 }
 
-static int ichac97StreamInit(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm)
+/**
+ * Opens an AC'97 stream.
+ * This will open an AC'97 stream with 2 (stereo) channels, 16-bit samples and
+ * the last set sample rate in the AC'97 mixer for this stream.
+ *
+ * @returns IPRT status code.
+ * @param   pThis               AC'97 device state.
+ * @param   pStream             Stream to initialize.
+ */
+static int ichac97StreamOpen(PAC97STATE pThis, PAC97STREAM pStream)
 {
     int rc = VINF_SUCCESS;
 
+    LogFunc(("[SD%RU8]\n", pStream->u8Strm));
+
     PDMAUDIOSTREAMCFG streamCfg;
     RT_ZERO(streamCfg);
 
-    switch (u8Strm)
+    switch (pStream->u8Strm)
     {
         case AC97SOUNDSOURCE_PI_INDEX:
             streamCfg.uHz               = ichac97MixerGet(pThis, AC97_PCM_LR_ADC_Rate);
@@ -911,37 +993,44 @@ static int ichac97StreamInit(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8St
 
     if (RT_SUCCESS(rc))
     {
-        pStream->State.cbFIFOW  = _4K; /** @todo Make FIFOW size configurable. */
-        pStream->State.offFIFOW = 0;
-        pStream->State.au8FIFOW = (uint8_t *)RTMemAllocZ(pStream->State.cbFIFOW);
-        if (!pStream->State.au8FIFOW)
-            rc = VERR_NO_MEMORY;
-    }
-
-    if (RT_SUCCESS(rc))
-    {
         if (streamCfg.uHz)
         {
-            streamCfg.cChannels     = 2; /** @todo Handle mono channels? */
+            streamCfg.cChannels     = 2;
             streamCfg.enmFormat     = PDMAUDIOFMT_S16;
             streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
 
-            rc = ichac97StreamInitEx(pThis, pStream, u8Strm, &streamCfg);
+            rc = ichac97StreamOpenEx(pThis, pStream, &streamCfg);
         }
         else
-        {
-            /* If no frequency is given, disable the stream. */
-            rc = ichac97StreamSetActive(pThis, pStream, false /* fActive */);
-        }
+            rc = VERR_INVALID_PARAMETER;
     }
 
-    LogFlowFunc(("[SD%RU8] rc=%Rrc\n", u8Strm, rc));
+    LogFlowFunc(("[SD%RU8] rc=%Rrc\n", pStream->u8Strm, rc));
     return rc;
 }
 
-static int ichac97StreamReInit(PAC97STATE pThis, PAC97STREAM pStrm)
+static void ichac97StreamClose(PAC97STREAM pStream)
 {
-    return ichac97StreamInit(pThis, pStrm, pStrm->u8Strm);
+    RT_NOREF(pStream);
+
+    LogFlowFunc(("[SD%RU8]\n", pStream->u8Strm));
+}
+
+/**
+ * Re-opens an AC'97 stream on the backend side with the current AC'97 mixer
+ * settings for this stream.
+ *
+ * @returns IPRT status code.
+ * @param   pThis               AC'97 device state.
+ * @param   pStream             Stream to re-open.
+ */
+static int ichac97StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream)
+{
+    LogFlowFunc(("[SD%RU8]\n", pStream->u8Strm));
+
+    ichac97StreamClose(pStream);
+
+    return ichac97StreamOpen(pThis, pStream);
 }
 
 static void ichac97StreamReset(PAC97STATE pThis, PAC97STREAM pStrm)
@@ -1022,7 +1111,7 @@ static int ichac97MixerSetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL e
                 rc = AudioMixerSetMasterVolume(pThis->pMixer,    &Vol);
                 break;
             case PDMAUDIOMIXERCTL_FRONT:
-                rc = AudioMixerSinkSetVolume(pThis->pSinkOutput, &Vol);
+                rc = AudioMixerSinkSetVolume(pThis->pSinkOut,    &Vol);
                 break;
 
             case PDMAUDIOMIXERCTL_MIC_IN:
@@ -1215,7 +1304,7 @@ static int ichac97WriteAudio(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbT
         /*
          * Write data to the mixer sink.
          */
-        rc = AudioMixerSinkWrite(pThis->pSinkOutput, AUDMIXOP_COPY, pu8FIFOW, cbToRead, &cbWritten);
+        rc = AudioMixerSinkWrite(pThis->pSinkOut, AUDMIXOP_COPY, pu8FIFOW, cbToRead, &cbWritten);
         if (RT_FAILURE(rc))
             break;
 
@@ -1279,7 +1368,7 @@ static void ichac97WriteBUP(PAC97STATE pThis, uint32_t cbElapsed)
         uint32_t cbToWrite = RT_MIN(cbElapsed, (uint32_t)sizeof(pThis->silence));
         uint32_t cbWrittenToStream;
 
-        int rc2 = AudioMixerSinkWrite(pThis->pSinkOutput, AUDMIXOP_COPY,
+        int rc2 = AudioMixerSinkWrite(pThis->pSinkOut, AUDMIXOP_COPY,
                                       pThis->silence, cbToWrite, &cbWrittenToStream);
         if (RT_SUCCESS(rc2))
         {
@@ -1365,7 +1454,7 @@ static void ichac97TimerMaybeStart(PAC97STATE pThis)
     pThis->uTimerTS = TMTimerGet(pThis->pTimer);
 
     /* Fire off timer. */
-    TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks);
+    TMTimerSet(pThis->pTimer, 0 /* u64Expire */);
 }
 
 static void ichac97TimerMaybeStop(PAC97STATE pThis)
@@ -1392,61 +1481,73 @@ static DECLCALLBACK(void) ichac97Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void
     Assert(pThis == PDMINS_2_DATA(pDevIns, PAC97STATE));
     AssertPtr(pThis);
 
-    STAM_PROFILE_START(&pThis->StatTimer, a);
+    int rc = RTCritSectEnter(&pThis->csTimer);
+    if (RT_SUCCESS(rc))
+    {
+        STAM_PROFILE_START(&pThis->StatTimer, a);
 
-    uint64_t cTicksNow     = TMTimerGet(pTimer);
+        uint64_t cTicksNow = TMTimerGet(pTimer);
 
-    LogFlowFuncEnter();
+        /* Update current time timestamp. */
+        pThis->uTimerTS = cTicksNow;
 
-    /* Update current time timestamp. */
-    pThis->uTimerTS = cTicksNow;
+        /* Flag indicating whether to kick the timer again for the next DMA transfer or sink processing. */
+        bool fDoNextTransfer = false;
 
-    /* Flag indicating whether to kick the timer again for a
-     * new data processing round. */
-    bool fKickTimer = false;
+        uint32_t cbToProcess;
 
-    uint32_t cbToProcess;
+        rc = AudioMixerSinkUpdate(pThis->pSinkLineIn);
+        if (RT_SUCCESS(rc))
+        {
+            cbToProcess = AudioMixerSinkGetReadable(pThis->pSinkLineIn);
+            if (cbToProcess)
+                rc = ichac97TransferAudio(pThis, &pThis->StreamLineIn, cbToProcess, NULL /* pcbProcessed */);
 
-    int rc = AudioMixerSinkUpdate(pThis->pSinkLineIn);
-    if (RT_SUCCESS(rc))
-    {
-        cbToProcess = AudioMixerSinkGetReadable(pThis->pSinkLineIn);
-        if (cbToProcess)
-            rc = ichac97TransferAudio(pThis, &pThis->StreamLineIn, cbToProcess, NULL /* pcbProcessed */);
+            if (AudioMixerSinkGetStatus(pThis->pSinkLineIn) & AUDMIXSINK_STS_DIRTY)
+                fDoNextTransfer = true;
+        }
 
-        fKickTimer |= !!(AudioMixerSinkGetStatus(pThis->pSinkLineIn) & AUDMIXSINK_STS_DIRTY);
-    }
+        rc = AudioMixerSinkUpdate(pThis->pSinkMicIn);
+        if (RT_SUCCESS(rc))
+        {
+            cbToProcess = AudioMixerSinkGetReadable(pThis->pSinkMicIn);
+            if (cbToProcess)
+                rc = ichac97TransferAudio(pThis, &pThis->StreamMicIn, cbToProcess, NULL /* pcbProcessed */);
 
-    rc = AudioMixerSinkUpdate(pThis->pSinkMicIn);
-    if (RT_SUCCESS(rc))
-    {
-        cbToProcess = AudioMixerSinkGetReadable(pThis->pSinkMicIn);
-        if (cbToProcess)
-            rc = ichac97TransferAudio(pThis, &pThis->StreamMicIn, cbToProcess, NULL /* pcbProcessed */);
+            if (AudioMixerSinkGetStatus(pThis->pSinkMicIn) & AUDMIXSINK_STS_DIRTY)
+                fDoNextTransfer = true;
+        }
 
-        fKickTimer |= !!(AudioMixerSinkGetStatus(pThis->pSinkMicIn) & AUDMIXSINK_STS_DIRTY);
-    }
+        rc = AudioMixerSinkUpdate(pThis->pSinkOut);
+        if (RT_SUCCESS(rc))
+        {
+            cbToProcess = AudioMixerSinkGetWritable(pThis->pSinkOut);
+            if (cbToProcess)
+                rc = ichac97TransferAudio(pThis, &pThis->StreamOut, cbToProcess, NULL /* pcbProcessed */);
 
-    rc = AudioMixerSinkUpdate(pThis->pSinkOutput);
-    if (RT_SUCCESS(rc))
-    {
-        cbToProcess = AudioMixerSinkGetWritable(pThis->pSinkOutput);
-        if (cbToProcess)
-            rc = ichac97TransferAudio(pThis, &pThis->StreamOut, cbToProcess, NULL /* pcbProcessed */);
+            if (AudioMixerSinkGetStatus(pThis->pSinkOut) & AUDMIXSINK_STS_DIRTY)
+                fDoNextTransfer = true;
+        }
 
-        fKickTimer |= !!(AudioMixerSinkGetStatus(pThis->pSinkOutput) & AUDMIXSINK_STS_DIRTY);
-    }
+        if (fDoNextTransfer)
+        {
+            /* Kick the timer again. */
+            uint64_t cTicks = pThis->cTimerTicks;
+            /** @todo adjust cTicks down by now much cbOutMin represents. */
+            TMTimerSet(pThis->pTimer, cTicksNow + cTicks);
+        }
+        else
+        {
+            LogFunc(("Stopping timer\n"));
+            LogRel3(("AC97: Stopping timer\n"));
+        }
 
-    if (   ASMAtomicReadBool(&pThis->fTimerActive)
-        || fKickTimer)
-    {
-        /* Kick the timer again. */
-        uint64_t cTicks = pThis->cTimerTicks;
-        /** @todo adjust cTicks down by now much cbOutMin represents. */
-        TMTimerSet(pThis->pTimer, cTicksNow + cTicks);
-    }
+        STAM_PROFILE_STOP(&pThis->StatTimer, a);
 
-    STAM_PROFILE_STOP(&pThis->StatTimer, a);
+        int rc2 = RTCritSectLeave(&pThis->csTimer);
+        if (RT_SUCCESS(rc))
+            rc2 = rc;
+    }
 }
 
 #endif /* !VBOX_WITH_AUDIO_CALLBACKS */
@@ -1457,7 +1558,11 @@ static int ichac97TransferAudio(PAC97STATE pThis, PAC97STREAM pStream, uint32_t
     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     /* pcbProcessed is optional. */
 
-    Log3Func(("[SD%RU8] cbToProcess=%RU32\n", pStream->u8Strm, cbToProcess));
+    int rc = RTCritSectEnter(&pStream->CritSect);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    LogFunc(("[SD%RU8] cbToProcess=%RU32\n", pStream->u8Strm, cbToProcess));
 
     PAC97BMREGS pRegs = &pStream->Regs;
 
@@ -1478,6 +1583,12 @@ static int ichac97TransferAudio(PAC97STATE pThis, PAC97STREAM pStream, uint32_t
 
         if (pcbProcessed)
             *pcbProcessed = 0;
+
+        Log3Func(("[SD%RU8] Halted\n", pStream->u8Strm));
+
+        rc = RTCritSectLeave(&pStream->CritSect);
+        AssertRC(rc);
+
         return VINF_SUCCESS;
     }
 
@@ -1485,13 +1596,16 @@ static int ichac97TransferAudio(PAC97STATE pThis, PAC97STREAM pStream, uint32_t
     if (pRegs->sr & AC97_SR_BCIS)
     {
         Log3Func(("[SD%RU8] BCIS set\n", pStream->u8Strm));
+
         if (pcbProcessed)
             *pcbProcessed = 0;
+
+        rc = RTCritSectLeave(&pStream->CritSect);
+        AssertRC(rc);
+
         return VINF_SUCCESS;
     }
 
-    int rc = VINF_SUCCESS;
-
     uint32_t cbLeft  = RT_MIN((uint32_t)(pRegs->picb << 1), cbToProcess);
     uint32_t cbTotal = 0;
 
@@ -1598,7 +1712,7 @@ static int ichac97TransferAudio(PAC97STATE pThis, PAC97STREAM pStream, uint32_t
                 ichac97StreamFetchBDLE(pThis, pStream);
             }
 
-            ichac97StreamUpdateStatus(pThis, pStream, new_sr);
+            ichac97StreamUpdateSR(pThis, pStream, new_sr);
         }
 
         if (/* All data processed? */
@@ -1610,6 +1724,9 @@ static int ichac97TransferAudio(PAC97STATE pThis, PAC97STREAM pStream, uint32_t
         }
     }
 
+    int rc2 = RTCritSectLeave(&pStream->CritSect);
+    AssertRC(rc2);
+
     if (RT_SUCCESS(rc))
     {
         if (pcbProcessed)
@@ -1632,7 +1749,17 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
     const uint32_t uPortIdx = Port - pThis->IOPortBase[1];
 
     PAC97STREAM pStream = ichac97GetStreamFromID(pThis, AC97_PORT2IDX(uPortIdx));
-    PAC97BMREGS pRegs   = pStream ? &pStream->Regs : NULL;
+    PAC97BMREGS pRegs   = NULL;
+
+    if (pStream)
+    {
+        pRegs = &pStream->Regs;
+
+        int rc2 = RTCritSectEnter(&pStream->CritSect);
+        AssertRC(rc2);
+    }
+
+    int rc = VINF_SUCCESS;
 
     switch (cbVal)
     {
@@ -1642,7 +1769,7 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
             {
                 case AC97_CAS:
                     /* Codec Access Semaphore Register */
-                    LogFlowFunc(("CAS %d\n", pThis->cas));
+                    Log3Func(("CAS %d\n", pThis->cas));
                     *pu32Val = pThis->cas;
                     pThis->cas = 1;
                     break;
@@ -1651,39 +1778,39 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
                 case MC_CIV:
                     /* Current Index Value Register */
                     *pu32Val = pRegs->civ;
-                    LogFlowFunc(("CIV[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("CIV[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 case PI_LVI:
                 case PO_LVI:
                 case MC_LVI:
                     /* Last Valid Index Register */
                     *pu32Val = pRegs->lvi;
-                    LogFlowFunc(("LVI[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("LVI[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 case PI_PIV:
                 case PO_PIV:
                 case MC_PIV:
                     /* Prefetched Index Value Register */
                     *pu32Val = pRegs->piv;
-                    LogFlowFunc(("PIV[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("PIV[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 case PI_CR:
                 case PO_CR:
                 case MC_CR:
                     /* Control Register */
                     *pu32Val = pRegs->cr;
-                    LogFlowFunc(("CR[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("CR[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 case PI_SR:
                 case PO_SR:
                 case MC_SR:
                     /* Status Register (lower part) */
-                    *pu32Val = pRegs->sr & 0xff; /** @todo r=andy Use RT_LO_U8. */
-                    LogFlowFunc(("SRb[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    *pu32Val = RT_LO_U8(pRegs->sr);
+                    Log3Func(("SRb[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 default:
                     *pu32Val = UINT32_MAX;
-                    LogFlowFunc(("U nabm readb %#x -> %#x\n", Port, *pu32Val));
+                    LogFunc(("U nabm readb %#x -> %#x\n", Port, *pu32Val));
                     break;
             }
             break;
@@ -1698,18 +1825,18 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
                 case MC_SR:
                     /* Status Register */
                     *pu32Val = pRegs->sr;
-                    LogFlowFunc(("SR[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("SR[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 case PI_PICB:
                 case PO_PICB:
                 case MC_PICB:
                     /* Position in Current Buffer */
                     *pu32Val = pRegs->picb;
-                    LogFlowFunc(("PICB[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("PICB[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 default:
                     *pu32Val = UINT32_MAX;
-                    LogFlowFunc(("U nabm readw %#x -> %#x\n", Port, *pu32Val));
+                    LogFunc(("U nabm readw %#x -> %#x\n", Port, *pu32Val));
                     break;
             }
             break;
@@ -1724,7 +1851,7 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
                 case MC_BDBAR:
                     /* Buffer Descriptor Base Address Register */
                     *pu32Val = pRegs->bdbar;
-                    LogFlowFunc(("BMADDR[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
+                    Log3Func(("BMADDR[%d] -> %#x\n", AC97_PORT2IDX(uPortIdx), *pu32Val));
                     break;
                 case PI_CIV:
                 case PO_CIV:
@@ -1733,8 +1860,8 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
                      *                Last Valid Index Register +
                      *                Status Register */
                     *pu32Val = pRegs->civ | (pRegs->lvi << 8) | (pRegs->sr << 16); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */
-                    LogFlowFunc(("CIV LVI SR[%d] -> %#x, %#x, %#x\n",
-                                 AC97_PORT2IDX(uPortIdx), pRegs->civ, pRegs->lvi, pRegs->sr));
+                    Log3Func(("CIV LVI SR[%d] -> %#x, %#x, %#x\n",
+                              AC97_PORT2IDX(uPortIdx), pRegs->civ, pRegs->lvi, pRegs->sr));
                     break;
                 case PI_PICB:
                 case PO_PICB:
@@ -1743,31 +1870,41 @@ static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser,
                      *                Prefetched Index Value Register +
                      *                Control Register */
                     *pu32Val = pRegs->picb | (pRegs->piv << 16) | (pRegs->cr << 24); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */
-                    LogFlowFunc(("PICB PIV CR[%d] -> %#x %#x %#x %#x\n",
-                                 AC97_PORT2IDX(uPortIdx), *pu32Val, pRegs->picb, pRegs->piv, pRegs->cr));
+                    Log3Func(("PICB PIV CR[%d] -> %#x %#x %#x %#x\n",
+                              AC97_PORT2IDX(uPortIdx), *pu32Val, pRegs->picb, pRegs->piv, pRegs->cr));
                     break;
                 case AC97_GLOB_CNT:
                     /* Global Control */
                     *pu32Val = pThis->glob_cnt;
-                    LogFlowFunc(("glob_cnt -> %#x\n", *pu32Val));
+                    Log3Func(("glob_cnt -> %#x\n", *pu32Val));
                     break;
                 case AC97_GLOB_STA:
                     /* Global Status */
                     *pu32Val = pThis->glob_sta | AC97_GS_S0CR;
-                    LogFlowFunc(("glob_sta -> %#x\n", *pu32Val));
+                    Log3Func(("glob_sta -> %#x\n", *pu32Val));
                     break;
                 default:
                     *pu32Val = UINT32_MAX;
-                    LogFlowFunc(("U nabm readl %#x -> %#x\n", Port, *pu32Val));
+                    LogFunc(("U nabm readl %#x -> %#x\n", Port, *pu32Val));
                     break;
             }
             break;
         }
 
         default:
-            return VERR_IOM_IOPORT_UNUSED;
+        {
+            AssertFailed();
+            rc = VERR_IOM_IOPORT_UNUSED;
+        }
     }
-    return VINF_SUCCESS;
+
+    if (pStream)
+    {
+        int rc2 = RTCritSectLeave(&pStream->CritSect);
+        AssertRC(rc2);
+    }
+
+    return rc;
 }
 
 /**
@@ -1783,7 +1920,19 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
     const uint32_t uPortIdx = Port - pThis->IOPortBase[1];
 
     PAC97STREAM pStream = ichac97GetStreamFromID(pThis, AC97_PORT2IDX(uPortIdx));
-    PAC97BMREGS pRegs   = pStream ? &pStream->Regs : NULL;
+    PAC97BMREGS pRegs   = NULL;
+
+    PAUDMIXSINK pSink   = NULL;
+
+    if (pStream)
+    {
+        pRegs = &pStream->Regs;
+        pSink = ichac97IndexToSink(pThis, pStream->u8Strm);
+        AssertPtr(pSink);
+
+        int rc2 = RTCritSectEnter(&pStream->CritSect);
+        AssertRC(rc2);
+    }
 
     switch (cbVal)
     {
@@ -1791,11 +1940,15 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
         {
             switch (uPortIdx)
             {
+                /*
+                 * Last Valid Index.
+                 */
                 case PI_LVI:
                 case PO_LVI:
                 case MC_LVI:
-                    /* Last Valid Index */
-                    if ((pRegs->cr & AC97_CR_RPBM) && (pRegs->sr & AC97_SR_DCH))
+                {
+                    if (   (pRegs->cr & AC97_CR_RPBM)
+                        && (pRegs->sr & AC97_SR_DCH))
                     {
                         pRegs->sr &= ~(AC97_SR_DCH | AC97_SR_CELV);
                         pRegs->civ = pRegs->piv;
@@ -1804,13 +1957,17 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
                         ichac97StreamFetchBDLE(pThis, pStream);
                     }
                     pRegs->lvi = u32Val % 32;
-                    LogFlowFunc(("LVI[%d] <- %#x\n", AC97_PORT2IDX(uPortIdx), u32Val));
+                    Log3Func(("[SD%RU8] LVI <- %#x\n", pStream->u8Strm, u32Val));
                     break;
+                }
+
+                /*
+                 * Control Registers.
+                 */
                 case PI_CR:
                 case PO_CR:
                 case MC_CR:
                 {
-                    /* Control Register */
                     if (u32Val & AC97_CR_RR) /* Busmaster reset */
                     {
                         ichac97StreamResetBMRegs(pThis, pStream);
@@ -1820,7 +1977,8 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
                         pRegs->cr = u32Val & AC97_CR_VALID_MASK;
                         if (!(pRegs->cr & AC97_CR_RPBM))
                         {
-                            ichac97StreamSetActive(pThis, pStream, false /* fActive */);
+                            ichac97StreamEnable(pThis, pStream, false /* fActive */);
+
                             pRegs->sr |= AC97_SR_DCH;
                         }
                         else
@@ -1828,25 +1986,33 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
                             pRegs->civ = pRegs->piv;
                             pRegs->piv = (pRegs->piv + 1) % 32;
 
+                            pRegs->sr &= ~AC97_SR_DCH;
+
+                            /* Fetch the initial BDLE descriptor. */
                             ichac97StreamFetchBDLE(pThis, pStream);
 
-                            pRegs->sr &= ~AC97_SR_DCH;
-                            ichac97StreamSetActive(pThis, pStream, true /* fActive */);
+                            ichac97StreamEnable(pThis, pStream, true /* fActive */);
                         }
                     }
-                    LogFlowFunc(("CR[%d] <- %#x (cr %#x)\n", AC97_PORT2IDX(uPortIdx), u32Val, pRegs->cr));
+                    Log3Func(("[SD%RU8] CR <- %#x (cr %#x)\n", pStream->u8Strm, u32Val, pRegs->cr));
                     break;
                 }
+
+                /*
+                 * Status Registers.
+                 */
                 case PI_SR:
                 case PO_SR:
                 case MC_SR:
-                    /* Status Register */
+                {
                     pRegs->sr |= u32Val & ~(AC97_SR_RO_MASK | AC97_SR_WCLEAR_MASK);
-                    ichac97StreamUpdateStatus(pThis, pStream, pRegs->sr & ~(u32Val & AC97_SR_WCLEAR_MASK));
-                    LogFlowFunc(("SR[%d] <- %#x (sr %#x)\n", AC97_PORT2IDX(uPortIdx), u32Val, pRegs->sr));
+                    ichac97StreamUpdateSR(pThis, pStream, pRegs->sr & ~(u32Val & AC97_SR_WCLEAR_MASK));
+                    Log3Func(("[SD%RU8] SR <- %#x (sr %#x)\n", pStream->u8Strm, u32Val, pRegs->sr));
                     break;
+                }
+
                 default:
-                    LogFlowFunc(("U nabm writeb %#x <- %#x\n", Port, u32Val));
+                    LogFunc(("Unimplemented: %#x <- %#x (Byte)\n", Port, u32Val));
                     break;
             }
             break;
@@ -1861,11 +2027,11 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
                 case MC_SR:
                     /* Status Register */
                     pRegs->sr |= u32Val & ~(AC97_SR_RO_MASK | AC97_SR_WCLEAR_MASK);
-                    ichac97StreamUpdateStatus(pThis, pStream, pRegs->sr & ~(u32Val & AC97_SR_WCLEAR_MASK));
-                    LogFlowFunc(("SR[%d] <- %#x (sr %#x)\n", AC97_PORT2IDX(uPortIdx), u32Val, pRegs->sr));
+                    ichac97StreamUpdateSR(pThis, pStream, pRegs->sr & ~(u32Val & AC97_SR_WCLEAR_MASK));
+                    Log3Func(("[SD%RU8] SR <- %#x (sr %#x)\n", pStream->u8Strm, u32Val, pRegs->sr));
                     break;
                 default:
-                    LogFlowFunc(("U nabm writew %#x <- %#x\n", Port, u32Val));
+                    LogFunc(("Unimplemented: %#x <- %#x (Word)\n", Port, u32Val));
                     break;
             }
             break;
@@ -1880,7 +2046,7 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
                 case MC_BDBAR:
                     /* Buffer Descriptor list Base Address Register */
                     pRegs->bdbar = u32Val & ~3;
-                    LogFlowFunc(("BDBAR[%d] <- %#x (bdbar %#x)\n", AC97_PORT2IDX(uPortIdx), u32Val, pRegs->bdbar));
+                    Log3Func(("[SD%RU8] BDBAR <- %#x (bdbar %#x)\n", AC97_PORT2IDX(uPortIdx), u32Val, pRegs->bdbar));
                     break;
                 case AC97_GLOB_CNT:
                     /* Global Control */
@@ -1890,16 +2056,16 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
                         ichac97ColdReset(pThis);
                     if (!(u32Val & (AC97_GC_WR | AC97_GC_CR)))
                         pThis->glob_cnt = u32Val & AC97_GC_VALID_MASK;
-                    LogFlowFunc(("glob_cnt <- %#x (glob_cnt %#x)\n", u32Val, pThis->glob_cnt));
+                    Log3Func(("glob_cnt <- %#x (glob_cnt %#x)\n", u32Val, pThis->glob_cnt));
                     break;
                 case AC97_GLOB_STA:
                     /* Global Status */
                     pThis->glob_sta &= ~(u32Val & AC97_GS_WCLEAR_MASK);
                     pThis->glob_sta |= (u32Val & ~(AC97_GS_WCLEAR_MASK | AC97_GS_RO_MASK)) & AC97_GS_VALID_MASK;
-                    LogFlowFunc(("glob_sta <- %#x (glob_sta %#x)\n", u32Val, pThis->glob_sta));
+                    Log3Func(("glob_sta <- %#x (glob_sta %#x)\n", u32Val, pThis->glob_sta));
                     break;
                 default:
-                    LogFlowFunc(("U nabm writel %#x <- %#x\n", Port, u32Val));
+                    LogFunc(("Unimplemented: %#x <- %#x (DWord)\n", Port, u32Val));
                     break;
             }
             break;
@@ -1909,6 +2075,13 @@ static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser
             AssertMsgFailed(("Port=%#x cb=%d u32=%#x\n", Port, cbVal, u32Val));
             break;
     }
+
+    if (pStream)
+    {
+        int rc2 = RTCritSectLeave(&pStream->CritSect);
+        AssertRC(rc2);
+    }
+
     return VINF_SUCCESS;
 }
 
@@ -1920,11 +2093,13 @@ static DECLCALLBACK(int) ichac97IOPortNAMRead(PPDMDEVINS pDevIns, void *pvUser,
     RT_NOREF(pDevIns);
     PAC97STATE pThis = (PAC97STATE)pvUser;
 
+    int rc = VINF_SUCCESS;
+
     switch (cbVal)
     {
         case 1:
         {
-            LogFlowFunc(("U nam readb %#x\n", Port));
+            Log3Func(("U nam readb %#x\n", Port));
             pThis->cas = 0;
             *pu32Val = UINT32_MAX;
             break;
@@ -1939,7 +2114,7 @@ static DECLCALLBACK(int) ichac97IOPortNAMRead(PPDMDEVINS pDevIns, void *pvUser,
             {
                 default:
                     *pu32Val = ichac97MixerGet(pThis, index);
-                    LogFlowFunc(("nam readw %#x -> %#x\n", Port, *pu32Val));
+                    Log3Func(("nam readw %#x -> %#x\n", Port, *pu32Val));
                     break;
             }
             break;
@@ -1947,16 +2122,20 @@ static DECLCALLBACK(int) ichac97IOPortNAMRead(PPDMDEVINS pDevIns, void *pvUser,
 
         case 4:
         {
-            LogFlowFunc(("U nam readl %#x\n", Port));
+            Log3Func(("U nam readl %#x\n", Port));
             pThis->cas = 0;
             *pu32Val = UINT32_MAX;
             break;
         }
 
         default:
-            return VERR_IOM_IOPORT_UNUSED;
+        {
+            AssertFailed();
+            rc = VERR_IOM_IOPORT_UNUSED;
+        }
     }
-    return VINF_SUCCESS;
+
+    return rc;
 }
 
 /**
@@ -1971,7 +2150,7 @@ static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser,
     {
         case 1:
         {
-            LogFlowFunc(("U nam writeb %#x <- %#x\n", Port, u32Val));
+            Log3Func(("U nam writeb %#x <- %#x\n", Port, u32Val));
             pThis->cas = 0;
             break;
         }
@@ -2019,34 +2198,34 @@ static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser,
                     break;
                 case AC97_Vendor_ID1:
                 case AC97_Vendor_ID2:
-                    LogFlowFunc(("Attempt to write vendor ID to %#x\n", u32Val));
+                    LogFunc(("Attempt to write vendor ID to %#x\n", u32Val));
                     break;
                 case AC97_Extended_Audio_ID:
-                    LogFlowFunc(("Attempt to write extended audio ID to %#x\n", u32Val));
+                    LogFunc(("Attempt to write extended audio ID to %#x\n", u32Val));
                     break;
                 case AC97_Extended_Audio_Ctrl_Stat:
                     if (!(u32Val & AC97_EACS_VRA))
                     {
                         ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 48000);
-                        ichac97StreamReInit(pThis, &pThis->StreamOut);
+                        ichac97StreamReOpen(pThis, &pThis->StreamOut);
 
                         ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate,    48000);
-                        ichac97StreamReInit(pThis, &pThis->StreamLineIn);
+                        ichac97StreamReOpen(pThis, &pThis->StreamLineIn);
                     }
                     if (!(u32Val & AC97_EACS_VRM))
                     {
                         ichac97MixerSet(pThis, AC97_MIC_ADC_Rate,       48000);
-                        ichac97StreamReInit(pThis, &pThis->StreamMicIn);
+                        ichac97StreamReOpen(pThis, &pThis->StreamMicIn);
                     }
-                    LogFlowFunc(("Setting extended audio control to %#x\n", u32Val));
+                    LogFunc(("Setting extended audio control to %#x\n", u32Val));
                     ichac97MixerSet(pThis, AC97_Extended_Audio_Ctrl_Stat, u32Val);
                     break;
                 case AC97_PCM_Front_DAC_Rate:
                     if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
                     {
                         ichac97MixerSet(pThis, index, u32Val);
-                        LogFlowFunc(("Set front DAC rate to %RU32\n", u32Val));
-                        ichac97StreamReInit(pThis, &pThis->StreamOut);
+                        LogFunc(("Set front DAC rate to %RU32\n", u32Val));
+                        ichac97StreamReOpen(pThis, &pThis->StreamOut);
                     }
                     else
                         AssertMsgFailed(("Attempt to set front DAC rate to %RU32, but VRA is not set\n", u32Val));
@@ -2055,8 +2234,8 @@ static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser,
                     if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRM)
                     {
                         ichac97MixerSet(pThis, index, u32Val);
-                        LogFlowFunc(("Set MIC ADC rate to %RU32\n", u32Val));
-                        ichac97StreamReInit(pThis, &pThis->StreamMicIn);
+                        LogFunc(("Set MIC ADC rate to %RU32\n", u32Val));
+                        ichac97StreamReOpen(pThis, &pThis->StreamMicIn);
                     }
                     else
                         AssertMsgFailed(("Attempt to set MIC ADC rate to %RU32, but VRM is not set\n", u32Val));
@@ -2065,14 +2244,14 @@ static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser,
                     if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
                     {
                         ichac97MixerSet(pThis, index, u32Val);
-                        LogFlowFunc(("Set front LR ADC rate to %RU32\n", u32Val));
-                        ichac97StreamReInit(pThis, &pThis->StreamLineIn);
+                        LogFunc(("Set front LR ADC rate to %RU32\n", u32Val));
+                        ichac97StreamReOpen(pThis, &pThis->StreamLineIn);
                     }
                     else
                         AssertMsgFailed(("Attempt to set LR ADC rate to %RU32, but VRA is not set\n", u32Val));
                     break;
                 default:
-                    LogFlowFunc(("U nam writew %#x <- %#x\n", Port, u32Val));
+                    LogFunc(("U nam writew %#x <- %#x\n", Port, u32Val));
                     ichac97MixerSet(pThis, index, u32Val);
                     break;
             }
@@ -2081,7 +2260,7 @@ static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser,
 
         case 4:
         {
-            LogFlowFunc(("U nam writel %#x <- %#x\n", Port, u32Val));
+            Log3Func(("U nam writel %#x <- %#x\n", Port, u32Val));
             pThis->cas = 0;
             break;
         }
@@ -2135,7 +2314,7 @@ DECLINLINE(PAC97STREAM) ichac97GetStreamFromID(PAC97STATE pThis, uint32_t uID)
         case AC97SOUNDSOURCE_PI_INDEX: return &pThis->StreamLineIn;
         case AC97SOUNDSOURCE_MC_INDEX: return &pThis->StreamMicIn;
         case AC97SOUNDSOURCE_PO_INDEX: return &pThis->StreamOut;
-        default:       break;
+        default:                       break;
     }
 
     return NULL;
@@ -2187,9 +2366,9 @@ static DECLCALLBACK(int) ichac97SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
 
     uint8_t active[AC97SOUNDSOURCE_LAST_INDEX];
 
-    active[AC97SOUNDSOURCE_PI_INDEX] = ichac97StreamIsActive(pThis, &pThis->StreamLineIn) ? 1 : 0;
-    active[AC97SOUNDSOURCE_PO_INDEX] = ichac97StreamIsActive(pThis, &pThis->StreamOut)    ? 1 : 0;
-    active[AC97SOUNDSOURCE_MC_INDEX] = ichac97StreamIsActive(pThis, &pThis->StreamMicIn)  ? 1 : 0;
+    active[AC97SOUNDSOURCE_PI_INDEX] = ichac97StreamIsEnabled(pThis, &pThis->StreamLineIn) ? 1 : 0;
+    active[AC97SOUNDSOURCE_PO_INDEX] = ichac97StreamIsEnabled(pThis, &pThis->StreamOut)    ? 1 : 0;
+    active[AC97SOUNDSOURCE_MC_INDEX] = ichac97StreamIsEnabled(pThis, &pThis->StreamMicIn)  ? 1 : 0;
 
     SSMR3PutMem(pSSM, active, sizeof(active));
 
@@ -2259,22 +2438,21 @@ static DECLCALLBACK(int) ichac97LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, ui
             ichac97MixerSetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER,
                              ichac97MixerGet(pThis, AC97_Headphone_Volume_Mute));
 
-    int rc = ichac97StreamsInit(pThis);
-    if (RT_SUCCESS(rc))
+    rc2 = ichac97StreamsInit(pThis);
+    if (RT_SUCCESS(rc2))
     {
         /** @todo r=andy Stream IDs are hardcoded to certain streams. */
-        rc = ichac97StreamSetActive(pThis, &pThis->StreamLineIn,    RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PI_INDEX]));
-        if (RT_SUCCESS(rc))
-            rc = ichac97StreamSetActive(pThis, &pThis->StreamMicIn, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_MC_INDEX]));
-        if (RT_SUCCESS(rc))
-            rc = ichac97StreamSetActive(pThis, &pThis->StreamOut,   RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PO_INDEX]));
+        rc2 = ichac97StreamEnable(pThis, &pThis->StreamLineIn,    RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PI_INDEX]));
+        if (RT_SUCCESS(rc2))
+            rc2 = ichac97StreamEnable(pThis, &pThis->StreamMicIn, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_MC_INDEX]));
+        if (RT_SUCCESS(rc2))
+            rc2 = ichac97StreamEnable(pThis, &pThis->StreamOut,   RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PO_INDEX]));
     }
 
     pThis->bup_flag  = 0;
     pThis->last_samp = 0;
 
-    LogFlowFuncLeaveRC(rc);
-    return rc;
+    return VINF_SUCCESS;
 }
 
 
@@ -2342,13 +2520,6 @@ static DECLCALLBACK(void) ichac97Reset(PPDMDEVINS pDevIns)
     ichac97MixerReset(pThis);
 
     /*
-     * Stop any audio currently playing and/or recording.
-     */
-    AudioMixerSinkCtl(pThis->pSinkOutput, AUDMIXSINKCMD_DISABLE);
-    AudioMixerSinkCtl(pThis->pSinkMicIn,  AUDMIXSINKCMD_DISABLE);
-    AudioMixerSinkCtl(pThis->pSinkLineIn, AUDMIXSINKCMD_DISABLE);
-
-    /*
      * Reset all streams.
      */
     ichac97StreamReset(pThis, &pThis->StreamLineIn);
@@ -2382,8 +2553,15 @@ static DECLCALLBACK(int) ichac97Destruct(PPDMDEVINS pDevIns)
     /* Sanity. */
     Assert(RTListIsEmpty(&pThis->lstDrv));
 
-    LogFlowFuncLeave();
-    return VINF_SUCCESS;
+    int rc;
+#ifndef VBOX_WITH_AUDIO_CALLBACKS
+    rc = RTCritSectDelete(&pThis->csTimer);
+#else
+    rc = VINF_SUCCESS;
+#endif
+
+    LogFlowFuncLeaveRC(rc);
+    return rc;
 }
 
 
@@ -2699,7 +2877,7 @@ static DECLCALLBACK(int) ichac97Construct(PPDMDEVINS pDevIns, int iInstance, PCF
         if (RT_SUCCESS(rc))
         {
             /* Add all required audio sinks. */
-            int rc2 = AudioMixerCreateSink(pThis->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
+            int rc2 = AudioMixerCreateSink(pThis->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOut);
             AssertRC(rc2);
 
             rc2 = AudioMixerCreateSink(pThis->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);
@@ -2820,18 +2998,20 @@ static DECLCALLBACK(int) ichac97Construct(PPDMDEVINS pDevIns, int iInstance, PCF
 # ifndef VBOX_WITH_AUDIO_CALLBACKS
     if (RT_SUCCESS(rc))
     {
-        /* Start the emulation timer. */
-        rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ichac97Timer, pThis,
-                                    TMTIMER_FLAGS_NO_CRIT_SECT, "DevIchAc97", &pThis->pTimer);
-        AssertRCReturn(rc, rc);
-
+        rc = RTCritSectInit(&pThis->csTimer);
         if (RT_SUCCESS(rc))
         {
-            pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimer) / uTimerHz;
-            pThis->uTimerTS    = TMTimerGet(pThis->pTimer);
-            LogFunc(("Timer ticks=%RU64 (%RU16 Hz)\n", pThis->cTimerTicks, uTimerHz));
+            /* Start the emulation timer. */
+            rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ichac97Timer, pThis,
+                                        TMTIMER_FLAGS_NO_CRIT_SECT, "DevIchAc97", &pThis->pTimer);
+            AssertRCReturn(rc, rc);
 
-            ichac97TimerMaybeStart(pThis);
+            if (RT_SUCCESS(rc))
+            {
+                pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimer) / uTimerHz;
+                pThis->uTimerTS    = TMTimerGet(pThis->pTimer);
+                LogFunc(("Timer ticks=%RU64 (%RU16 Hz)\n", pThis->cTimerTicks, uTimerHz));
+            }
         }
     }
 # else
diff --git a/src/VBox/Devices/Audio/DrvAudio.cpp b/src/VBox/Devices/Audio/DrvAudio.cpp
index 4cb01f1..39c6533 100644
--- a/src/VBox/Devices/Audio/DrvAudio.cpp
+++ b/src/VBox/Devices/Audio/DrvAudio.cpp
@@ -43,8 +43,8 @@
 static DECLCALLBACK(int) drvAudioStreamDestroy(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream);
 static int drvAudioStreamControlInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd);
 static int drvAudioStreamControlInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd);
-static int drvAudioStreamDestroyInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream);
-static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
+static int drvAudioStreamDestroyInBackendInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream);
+static int drvAudioStreamUninitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
 static int drvAudioStreamInitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest);
 static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
 static int drvAudioStreamReInitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
@@ -149,7 +149,12 @@ DECLINLINE(PPDMAUDIOSTREAM) drvAudioGetHostStream(PPDMAUDIOSTREAM pStream)
                                : pStream->pPair;
     if (pHstStream)
     {
-        Assert(pHstStream->enmCtx == PDMAUDIOSTREAMCTX_HOST);
+        AssertReleaseMsg(pHstStream->enmCtx == PDMAUDIOSTREAMCTX_HOST,
+                         ("Stream '%s' resolved as host part is not marked as such (enmCtx=%RU32)\n",
+                          pHstStream->szName, pHstStream->enmCtx));
+
+        AssertReleaseMsg(pHstStream->pPair != NULL,
+                         ("Stream '%s' resolved as host part has no guest part (anymore)\n", pHstStream->szName));
     }
     else
         LogRel(("Audio: Warning: Stream '%s' does not have a host stream (anymore)\n", pStream->szName));
@@ -527,8 +532,9 @@ static int drvAudioStreamInitInternal(PDRVAUDIO pThis,
     LogFunc(("[%s] Requested host format:\n", pStream->szName));
     DrvAudioHlpStreamCfgPrint(pCfgHost);
 #else
+    LogRel2(("Audio: Creating stream '%s'\n", pStream->szName));
     LogRel2(("Audio: Requested %s host format for '%s': %RU32Hz, %s, %RU8 %s\n",
-             pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback",  pStream->szName,
+             pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStream->szName,
              pCfgHost->uHz, DrvAudioHlpAudFmtToStr(pCfgHost->enmFormat),
              pCfgHost->cChannels, pCfgHost->cChannels == 0 ? "Channel" : "Channels"));
 #endif
@@ -537,7 +543,7 @@ static int drvAudioStreamInitInternal(PDRVAUDIO pThis,
                                                    pCfgHost /* pCfgReq */, &CfgHostAcq /* pCfgAcq */);
     if (RT_FAILURE(rc))
     {
-        LogFlowFunc(("[%s] Initializing stream in host backend failed with rc=%Rrc\n", pStream->szName, rc));
+        LogRel2(("Audio: Creating stream '%s' in backend failed with %Rrc\n", pStream->szName, rc));
         return rc;
     }
 
@@ -639,6 +645,9 @@ static int drvAudioStreamInitInternal(PDRVAUDIO pThis,
     /* Make a copy of the host stream configuration. */
     memcpy(&pGstStream->Cfg, pCfgGuest, sizeof(PDMAUDIOSTREAMCFG));
 
+    if (RT_FAILURE(rc))
+        LogRel2(("Audio: Creating stream '%s' failed with %Rrc\n", pStream->szName, rc));
+
     LogFlowFunc(("[%s] Returning %Rrc\n", pStream->szName, rc));
     return rc;
 }
@@ -916,6 +925,13 @@ static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStrea
                 {
                     Log3Func(("[%s] %RU32 captured samples mixed\n", pHstStream->szName, cSamplesMixed));
                 }
+                else if (RT_FAILURE(rc))
+                {
+                    if (rc == VERR_BUFFER_OVERFLOW)
+                        LogRel2(("Audio: Guest input stream '%s' full, expect stuttering audio capture\n", pGstStream->szName));
+                    else
+                        LogRel2(("Audio: Mixing to guest input stream '%s' failed: %Rrc\n", pGstStream->szName, rc));
+                }
             }
             else
             {
@@ -934,6 +950,13 @@ static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStrea
                           pHstStream->szName, cSamplesMixed,
                           AudioMixBufUsed(&pGstStream->MixBuf), AudioMixBufLive(&pGstStream->MixBuf)));
             }
+            else if (RT_FAILURE(rc))
+            {
+                if (rc == VERR_BUFFER_OVERFLOW)
+                    LogRel2(("Audio: Host output stream '%s' full, expect stuttering audio output\n", pHstStream->szName));
+                else
+                    LogRel2(("Audio: Mixing to host output stream '%s' failed: %Rrc\n", pHstStream->szName, rc));
+            }
 
             uint32_t cSamplesLeft = AudioMixBufUsed(&pGstStream->MixBuf);
             if (!cSamplesLeft) /* No samples (anymore)? */
@@ -1034,8 +1057,9 @@ static DECLCALLBACK(int) drvAudioStreamPlay(PPDMIAUDIOCONNECTOR pInterface,
                                   rc = VERR_NOT_AVAILABLE);
 
         AssertPtr(pThis->pHostDrvAudio->pfnStreamGetStatus);
-        PDMAUDIOSTRMSTS strmSts = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream);
-        if (!(strmSts & PDMAUDIOSTRMSTS_FLAG_INITIALIZED))
+        PDMAUDIOSTRMSTS stsBackend = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream);
+
+        if (!(stsBackend & PDMAUDIOSTRMSTS_FLAG_INITIALIZED))
         {
             LogFunc(("[%s] Backend not initialized (anymore), re-initializing ...\n", pHstStream->szName));
             rc = drvAudioStreamReInitInternal(pThis, pStream);
@@ -1049,8 +1073,8 @@ static DECLCALLBACK(int) drvAudioStreamPlay(PPDMIAUDIOCONNECTOR pInterface,
         uint32_t cSamplesLive = AudioMixBufLive(&pGstStream->MixBuf);
         if (cSamplesLive)
         {
-            if (   (strmSts & PDMAUDIOSTRMSTS_FLAG_INITIALIZED)
-                && (strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE))
+            if (   (stsBackend & PDMAUDIOSTRMSTS_FLAG_ENABLED)
+                && (stsBackend & PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE))
             {
                 AssertPtr(pThis->pHostDrvAudio->pfnStreamPlay);
                 rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream, NULL /* pvBuf */, 0 /* cbBuf */,
@@ -1156,8 +1180,10 @@ static DECLCALLBACK(int) drvAudioStreamCapture(PPDMIAUDIOCONNECTOR pInterface,
                                    pStream->szName, pStream->cRefs, pStream->fStatus, pStream->enmCtx),
                                   rc = VERR_NOT_AVAILABLE);
 
-        PDMAUDIOSTRMSTS strmSts = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream);
-        if (!(strmSts & PDMAUDIOSTRMSTS_FLAG_INITIALIZED))
+        AssertPtr(pThis->pHostDrvAudio->pfnStreamGetStatus);
+        PDMAUDIOSTRMSTS stsBackend = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream);
+
+        if (!(stsBackend & PDMAUDIOSTRMSTS_FLAG_INITIALIZED))
         {
             LogFunc(("[%s] Backend not initialized (anymore), re-initializing ...\n", pHstStream->szName));
             rc = drvAudioStreamReInitInternal(pThis, pStream);
@@ -1167,8 +1193,8 @@ static DECLCALLBACK(int) drvAudioStreamCapture(PPDMIAUDIOCONNECTOR pInterface,
         uint32_t cSamplesLive = AudioMixBufLive(&pGstStream->MixBuf);
         if (!cSamplesLive)
         {
-            if (   (strmSts & PDMAUDIOSTRMSTS_FLAG_INITIALIZED)
-                && (strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE))
+            if (   (stsBackend & PDMAUDIOSTRMSTS_FLAG_ENABLED)
+                && (stsBackend & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE))
             {
                 rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream, NULL /* pvBuf */, 0 /* cbBuf */,
                                                             &cSamplesCaptured);
@@ -1185,7 +1211,7 @@ static DECLCALLBACK(int) drvAudioStreamCapture(PPDMIAUDIOCONNECTOR pInterface,
                 }
             }
 
-            Log3Func(("[%s] strmSts=0x%x, cSamplesCaptured=%RU32, rc=%Rrc\n", pHstStream->szName, strmSts, cSamplesCaptured, rc));
+            Log3Func(("[%s] strmSts=0x%x, cSamplesCaptured=%RU32, rc=%Rrc\n", pHstStream->szName, stsBackend, cSamplesCaptured, rc));
         }
 
     } while (0);
@@ -1444,6 +1470,8 @@ static int drvAudioInit(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
     AssertPtrReturn(pCfgHandle, VERR_INVALID_POINTER);
     AssertPtrReturn(pDrvIns,    VERR_INVALID_POINTER);
 
+    LogRel2(("Audio: Verbose logging enabled\n"));
+
     PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO);
     LogFlowFunc(("pThis=%p, pDrvIns=%p\n", pThis, pDrvIns));
 
@@ -1686,14 +1714,22 @@ static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface,
     {
         if (pGstStrm)
         {
-            drvAudioStreamDestroyInternal(pThis, pGstStrm);
-            pGstStrm = NULL;
+            int rc2 = drvAudioStreamUninitInternal(pThis, pGstStrm);
+            if (RT_SUCCESS(rc2))
+            {
+                RTMemFree(pGstStrm);
+                pGstStrm = NULL;
+            }
         }
 
         if (pHstStrm)
         {
-            drvAudioStreamDestroyInternal(pThis, pHstStrm);
-            pHstStrm = NULL;
+            int rc2 = drvAudioStreamUninitInternal(pThis, pHstStrm);
+            if (RT_SUCCESS(rc2))
+            {
+                RTMemFree(pHstStrm);
+                pHstStrm = NULL;
+            }
         }
     }
     else
@@ -1897,7 +1933,7 @@ static DECLCALLBACK(PDMAUDIOSTRMSTS) drvAudioStreamGetStatus(PPDMIAUDIOCONNECTOR
     if (pHstStream)
     {
         strmSts = pHstStream->fStatus;
-        Log3Func(("%s: strmSts=0x%x\n", pHstStream->szName, strmSts));
+        Log3Func(("[%s] strmSts=0x%x\n", pHstStream->szName, strmSts));
     }
 
     rc2 = RTCritSectLeave(&pThis->CritSect);
@@ -1949,38 +1985,40 @@ static DECLCALLBACK(int) drvAudioStreamDestroy(PPDMIAUDIOCONNECTOR pInterface, P
         PPDMAUDIOSTREAM pHstStream = drvAudioGetHostStream(pStream);
         PPDMAUDIOSTREAM pGstStream = pHstStream ? pHstStream->pPair : pStream;
 
-        LogFlowFunc(("\tHost : %s\n", pHstStream ? pHstStream->szName : "<None>"));
-        LogFlowFunc(("\tGuest: %s\n", pGstStream ? pGstStream->szName : "<None>"));
+        LogRel2(("Audio: Destroying host stream '%s' (guest stream '%s')\n",
+                 pHstStream ? pHstStream->szName : "<None>",
+                 pGstStream ? pGstStream->szName : "<None>"));
 
         /* Should prevent double frees. */
         Assert(pHstStream != pGstStream);
 
         if (pHstStream)
         {
-            pHstStream->pPair = NULL;
-            RTListNodeRemove(&pHstStream->Node);
-        }
-
-        if (pGstStream)
-        {
-            pGstStream->pPair = NULL;
-            RTListNodeRemove(&pGstStream->Node);
-        }
-
-        if (pHstStream)
-        {
-            rc = drvAudioStreamDestroyInternal(pThis, pHstStream);
-            AssertRC(rc);
+            rc = drvAudioStreamUninitInternal(pThis, pHstStream);
+            if (RT_SUCCESS(rc))
+            {
+                RTListNodeRemove(&pHstStream->Node);
 
-            pHstStream = NULL;
+                RTMemFree(pHstStream);
+                pHstStream = NULL;
+            }
+            else
+                LogRel2(("Audio: Uninitializing host stream '%s' failed with %Rrc\n", pHstStream->szName, rc));
         }
 
-        if (pGstStream)
+        if (   RT_SUCCESS(rc)
+            && pGstStream)
         {
-            rc = drvAudioStreamDestroyInternal(pThis, pGstStream);
-            AssertRC(rc);
+            rc = drvAudioStreamUninitInternal(pThis, pGstStream);
+            if (RT_SUCCESS(rc))
+            {
+                RTListNodeRemove(&pGstStream->Node);
 
-            pGstStream = NULL;
+                RTMemFree(pGstStream);
+                pGstStream = NULL;
+            }
+            else
+                LogRel2(("Audio: Uninitializing guest stream '%s' failed with %Rrc\n", pGstStream->szName, rc));
         }
     }
 
@@ -2011,7 +2049,7 @@ static DECLCALLBACK(int) drvAudioStreamDestroy(PPDMIAUDIOCONNECTOR pInterface, P
  * @param   pThis               Pointer to driver instance.
  * @param   pHstStream          Host audio stream to call the backend destruction for.
  */
-static int drvAudioStreamDestroyInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream)
+static int drvAudioStreamDestroyInBackendInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream)
 {
     AssertPtrReturn(pThis,      VERR_INVALID_POINTER);
     AssertPtrReturn(pHstStream, VERR_INVALID_POINTER);
@@ -2038,14 +2076,13 @@ static int drvAudioStreamDestroyInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM
 }
 
 /**
- * Destroys an audio stream.
+ * Uninitializes an audio stream.
  *
  * @returns IPRT status code.
  * @param   pThis               Pointer to driver instance.
- * @param   pStream             Pointer to audio stream to destroy.
- *                              That pointer will be invalid after successful destruction.
+ * @param   pStream             Pointer to audio stream to uninitialize.
  */
-static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream)
+static int drvAudioStreamUninitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream)
 {
     AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
@@ -2083,7 +2120,7 @@ static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStrea
     }
     else if (pStream->enmCtx == PDMAUDIOSTREAMCTX_HOST)
     {
-        rc = drvAudioStreamDestroyInternalBackend(pThis, pStream);
+        rc = drvAudioStreamDestroyInBackendInternal(pThis, pStream);
 
         if (pStream->enmDir == PDMAUDIODIR_IN)
         {
@@ -2103,14 +2140,18 @@ static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStrea
 
     if (RT_SUCCESS(rc))
     {
+        /* Make sure that the pair (if any) knows that we're not valid anymore. */
+        if (pStream->pPair)
+            pStream->pPair->pPair = NULL;
+
+        /* Reset status. */
+        pStream->fStatus = PDMAUDIOSTRMSTS_FLAG_NONE;
+
+        /* Clear name. */
+        pStream->szName[0] = '\0';
+
         /* Destroy mixing buffer. */
         AudioMixBufDestroy(&pStream->MixBuf);
-
-        if (pStream)
-        {
-            RTMemFree(pStream);
-            pStream = NULL;
-        }
     }
 
     LogFlowFunc(("Returning %Rrc\n", rc));
@@ -2151,7 +2192,7 @@ static DECLCALLBACK(void) drvAudioPowerOff(PPDMDRVINS pDrvIns)
      * in drvAudioDestruct(). */
     PPDMAUDIOSTREAM pStream;
     RTListForEach(&pThis->lstHstStreams, pStream, PDMAUDIOSTREAM, Node)
-        drvAudioStreamDestroyInternalBackend(pThis, pStream);
+        drvAudioStreamDestroyInBackendInternal(pThis, pStream);
 
     /*
      * Last call for the driver below us.
@@ -2286,10 +2327,34 @@ static DECLCALLBACK(void) drvAudioDestruct(PPDMDRVINS pDrvIns)
 
     PPDMAUDIOSTREAM pStream, pStreamNext;
     RTListForEachSafe(&pThis->lstHstStreams, pStream, pStreamNext, PDMAUDIOSTREAM, Node)
-        drvAudioStreamDestroyInternal(pThis, pStream);
+    {
+        rc2 = drvAudioStreamUninitInternal(pThis, pStream);
+        if (RT_SUCCESS(rc2))
+        {
+            RTListNodeRemove(&pStream->Node);
+
+            RTMemFree(pStream);
+            pStream = NULL;
+        }
+    }
+
+    /* Sanity. */
+    Assert(RTListIsEmpty(&pThis->lstHstStreams));
 
     RTListForEachSafe(&pThis->lstGstStreams, pStream, pStreamNext, PDMAUDIOSTREAM, Node)
-        drvAudioStreamDestroyInternal(pThis, pStream);
+    {
+        rc2 = drvAudioStreamUninitInternal(pThis, pStream);
+        if (RT_SUCCESS(rc2))
+        {
+            RTListNodeRemove(&pStream->Node);
+
+            RTMemFree(pStream);
+            pStream = NULL;
+        }
+    }
+
+    /* Sanity. */
+    Assert(RTListIsEmpty(&pThis->lstGstStreams));
 
 #ifdef VBOX_WITH_AUDIO_CALLBACKS
     /*
diff --git a/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp b/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
index 3c2f6fc..05fccc7 100644
--- a/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
+++ b/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
@@ -39,6 +39,9 @@
 #include <CoreServices/CoreServices.h>
 #include <AudioUnit/AudioUnit.h>
 #include <AudioToolbox/AudioConverter.h>
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+# include <AudioToolbox/AudioToolbox.h>
+#endif
 
 #if 0
 # include <iprt/file.h>
@@ -138,6 +141,43 @@ static int coreAudioStreamCfgToASBD(PPDMAUDIOSTREAMCFG pCfg, AudioStreamBasicDes
     return rc;
 }
 
+static int coreAudioASBDToStreamCfg(AudioStreamBasicDescription *pASBD, PPDMAUDIOSTREAMCFG pCfg)
+{
+    AssertPtrReturn(pASBD, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(pCfg,  VERR_INVALID_PARAMETER);
+
+    pCfg->cChannels     = pASBD->mChannelsPerFrame;
+    pCfg->uHz           = (uint32_t)pASBD->mSampleRate;
+    pCfg->enmEndianness = PDMAUDIOENDIANNESS_LITTLE;
+
+    int rc = VINF_SUCCESS;
+
+    if (pASBD->mFormatFlags & kAudioFormatFlagIsSignedInteger)
+    {
+        switch (pASBD->mBitsPerChannel)
+        {
+            case 8:  pCfg->enmFormat = PDMAUDIOFMT_S8;  break;
+            case 16: pCfg->enmFormat = PDMAUDIOFMT_S16; break;
+            case 32: pCfg->enmFormat = PDMAUDIOFMT_S32; break;
+            default: rc = VERR_NOT_SUPPORTED;           break;
+        }
+    }
+    else
+    {
+        switch (pASBD->mBitsPerChannel)
+        {
+            case 8:  pCfg->enmFormat = PDMAUDIOFMT_U8;  break;
+            case 16: pCfg->enmFormat = PDMAUDIOFMT_U16; break;
+            case 32: pCfg->enmFormat = PDMAUDIOFMT_U32; break;
+            default: rc = VERR_NOT_SUPPORTED;           break;
+        }
+    }
+
+    AssertRC(rc);
+    return rc;
+}
+
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
 static OSStatus coreAudioSetFrameBufferSize(AudioDeviceID deviceID, bool fInput, UInt32 cReqSize, UInt32 *pcActSize)
 {
     AudioObjectPropertyScope propScope = fInput
@@ -237,6 +277,7 @@ static int coreAudioCFStringToCString(const CFStringRef pCFString, char **ppszSt
     *ppszString = pszResult;
     return VINF_SUCCESS;
 }
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
 
 #if 0 /* unused */
 static AudioDeviceID coreAudioDeviceUIDtoID(const char* pszUID)
@@ -288,8 +329,10 @@ static AudioDeviceID coreAudioDeviceUIDtoID(const char* pszUID)
 /*********************************************************************************************************************************
 *   Global Variables                                                                                                             *
 *********************************************************************************************************************************/
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
 /* Error code which indicates "End of data" */
 static const OSStatus g_caConverterEOFDErr = 0x656F6664; /* 'eofd' */
+#endif
 
 
 /*********************************************************************************************************************************
@@ -320,20 +363,44 @@ typedef struct DRVHOSTCOREAUDIO
  * Simple structure for maintaining a stream's callback context.
  ** @todo Remove this as soon as we have unified input/output streams in this backend.
  */
-typedef struct COREAUDIOSTREAMCBCTX
+typedef struct COREAUDIOSTREAM
 {
     /** Pointer to driver instance. */
-    PDRVHOSTCOREAUDIO       pThis;
+    PDRVHOSTCOREAUDIO           pThis;
     /** The stream's direction. */
-    PDMAUDIODIR             enmDir;
+    PDMAUDIODIR                 enmDir;
     union
     {
         /** Pointer to self, if it's an input stream. */
-        PCOREAUDIOSTREAMIN  pIn;
+        PCOREAUDIOSTREAMIN      pIn;
         /** Pointer to self, if it's an output stream. */
-        PCOREAUDIOSTREAMOUT pOut;
+        PCOREAUDIOSTREAMOUT     pOut;
     };
-} COREAUDIOSTREAMCBCTX, *PCOREAUDIOSTREAMCBCTX;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    /** The stream's thread handle for maintaining the audio queue. */
+    RTTHREAD                    hThread;
+    /** Flag indicating to start a stream's data processing. */
+    bool                        fRun;
+    /** Whether the stream is in a running (active) state or not.
+     *  For playback streams this means that audio data can be (or is being) played,
+     *  for capturing streams this means that audio data is being captured (if available). */
+    bool                        fIsRunning;
+    /** Thread shutdown indicator. */
+    bool                        fShutdown;
+    /** Critical section for serializing access between thread + callbacks. */
+    RTCRITSECT                  CritSect;
+    /** The actual audio queue being used. */
+    AudioQueueRef               audioQueue;
+    /** The audio buffers which are used with the above audio queue. */
+    AudioQueueBufferRef         audioBuffer[3];
+    /** The acquired (final) audio format for this stream. */
+    AudioStreamBasicDescription asbdStream;
+    /** The device' UUID. */
+    CFStringRef                 UUID;
+    /** An internal ring buffer for transferring data from/to the rendering callbacks. */
+    PRTCIRCBUF                  pCircBuf;
+#endif
+} COREAUDIOSTREAM, *PCOREAUDIOSTREAM;
 
 /**
  * Structure for keeping a conversion callback context.
@@ -344,7 +411,7 @@ typedef struct COREAUDIOCONVCBCTX
     /** Pointer to stream context this converter callback context
      *  is bound to. */
     /** @todo Remove this as soon as we have unified input/output streams in this backend. */
-    COREAUDIOSTREAMCBCTX        pStream;
+    COREAUDIOSTREAM             Stream;
     /** Source stream description. */
     AudioStreamBasicDescription asbdSrc;
     /** Destination stream description. */
@@ -363,6 +430,9 @@ typedef struct COREAUDIOSTREAMOUT
     /** Host output stream.
      *  Note: Always must come first in this structure! */
     PDMAUDIOSTREAM              Stream;
+    /** Common stream data.
+     *  @todo Remove this as soon as we have unified input/output streams in this backend. */
+    COREAUDIOSTREAM             Common;
     /** Stream description which is default on the device. */
     AudioStreamBasicDescription deviceFormat;
     /** Stream description which is selected for using with VBox. */
@@ -380,10 +450,6 @@ typedef struct COREAUDIOSTREAMOUT
     bool                        fDefDevChgListReg;
     /** Flag whether the "device state changed" listener was registered. */
     bool                        fDevStateChgListReg;
-    /** Callback context for this stream for handing this stream in to
-     *  a CoreAudio callback.
-     ** @todo Remove this as soon as we have unified input/output streams in this backend. */
-    COREAUDIOSTREAMCBCTX        cbCtx;
 } COREAUDIOSTREAMOUT, *PCOREAUDIOSTREAMOUT;
 
 typedef struct COREAUDIOSTREAMIN
@@ -391,6 +457,9 @@ typedef struct COREAUDIOSTREAMIN
     /** Host input stream.
      *  Note: Always must come first in this structure! */
     PDMAUDIOSTREAM              Stream;
+    /** Common stream data.
+     *  @todo Remove this as soon as we have unified input/output streams in this backend. */
+    COREAUDIOSTREAM             Common;
     /** Stream description which is default on the device. */
     AudioStreamBasicDescription deviceFormat;
     /** Stream description which is selected for using with VBox. */
@@ -399,7 +468,7 @@ typedef struct COREAUDIOSTREAMIN
     AudioDeviceID               deviceID;
     /** The AudioUnit used. */
     AudioUnit                   audioUnit;
-    /** A ring buffer for transferring data from the capturing thread. */
+    /** A ring buffer for transferring data to the playback thread. */
     PRTCIRCBUF                  pCircBuf;
     /** The audio converter if necessary. NULL if no converter is being used. */
     AudioConverterRef           pConverter;
@@ -414,10 +483,6 @@ typedef struct COREAUDIOSTREAMIN
     bool                        fDefDevChgListReg;
     /** Flag whether the "device state changed" listener was registered. */
     bool                        fDevStateChgListReg;
-    /** Callback context for this stream for handing this stream in to
-     *  a CoreAudio callback.
-     ** @todo Remove this as soon as we have unified input/output streams in this backend. */
-    COREAUDIOSTREAMCBCTX        cbCtx;
 } COREAUDIOSTREAMIN, *PCOREAUDIOSTREAMIN;
 
 
@@ -425,9 +490,22 @@ typedef struct COREAUDIOSTREAMIN
 *   Internal Functions                                                                                                           *
 *********************************************************************************************************************************/
 static OSStatus coreAudioPlaybackAudioDevicePropertyChanged(AudioObjectID propertyID, UInt32 cAddresses, const AudioObjectPropertyAddress properties[], void *pvUser);
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
+static int coreAudioStreamInitIn(PCOREAUDIOSTREAMIN pStreamIn, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq);
+static int coreAudioStreamInitOut(PCOREAUDIOSTREAMOUT pStreamOut, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq);
 static OSStatus coreAudioPlaybackCb(void *pvUser, AudioUnitRenderActionFlags *pActionFlags, const AudioTimeStamp *pAudioTS, UInt32 uBusID, UInt32 cFrames, AudioBufferList* pBufData);
+#endif
 
+static int coreAudioControlStreamIn(PCOREAUDIOSTREAMIN pCAStreamIn, PDMAUDIOSTREAMCMD enmStreamCmd);
+static int coreAudioControlStreamOut(PCOREAUDIOSTREAMOUT pCAStreamOut, PDMAUDIOSTREAMCMD enmStreamCmd);
 
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+static void coreAudioInputQueueCb(void *pvUser, AudioQueueRef audioQueue, AudioQueueBufferRef audioBuffer, const AudioTimeStamp *pAudioTS, UInt32 cPacketDesc, const AudioStreamPacketDescription *paPacketDesc);
+static void coreAudioOutputQueueCb(void *pvUser, AudioQueueRef audioQueue, AudioQueueBufferRef audioBuffer);
+#endif
+
+
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
 /**
  * Initializes a conversion callback context.
  *
@@ -472,6 +550,7 @@ static void coreAudioUninitConvCbCtx(PCOREAUDIOCONVCBCTX pConvCbCtx)
 
     pConvCbCtx->bufLstSrc.mNumberBuffers = 0;
 }
+#endif /* VBOX_WITH_AUDIO_CA_CONVERTER */
 
 /**
  * Does a (Re-)enumeration of the host's playback + recording devices.
@@ -645,8 +724,8 @@ static OSStatus drvHostCoreAudioDeviceStateChanged(AudioObjectID propertyID,
     RT_NOREF(propertyID, cAddresses, paProperties)
     LogFlowFunc(("propertyID=%u cAddresses=%u pvUser=%p\n", propertyID, cAddresses, pvUser));
 
-    PCOREAUDIOSTREAMCBCTX pCbCtx = (PCOREAUDIOSTREAMCBCTX)pvUser;
-    AssertPtr(pCbCtx);
+    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser;
+    AssertPtr(pCAStream);
 
     UInt32 uAlive = 1;
     UInt32 uSize  = sizeof(UInt32);
@@ -654,8 +733,8 @@ static OSStatus drvHostCoreAudioDeviceStateChanged(AudioObjectID propertyID,
     AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
                                            kAudioObjectPropertyElementMaster };
 
-    AudioDeviceID deviceID = pCbCtx->enmDir == PDMAUDIODIR_IN
-                           ? pCbCtx->pIn->deviceID : pCbCtx->pOut->deviceID;
+    AudioDeviceID deviceID = pCAStream->enmDir == PDMAUDIODIR_IN
+                           ? pCAStream->pIn->deviceID : pCAStream->pOut->deviceID;
 
     OSStatus err = AudioObjectGetPropertyData(deviceID, &propAdr, 0, NULL, &uSize, &uAlive);
 
@@ -668,11 +747,11 @@ static OSStatus drvHostCoreAudioDeviceStateChanged(AudioObjectID propertyID,
 
     if (fIsDead)
     {
-        switch (pCbCtx->enmDir)
+        switch (pCAStream->enmDir)
         {
             case PDMAUDIODIR_IN:
             {
-                PCOREAUDIOSTREAMIN pStreamIn = pCbCtx->pIn;
+                PCOREAUDIOSTREAMIN pStreamIn = pCAStream->pIn;
 
                 /* We move the reinitialization to the next output event.
                  * This make sure this thread isn't blocked and the
@@ -685,7 +764,7 @@ static OSStatus drvHostCoreAudioDeviceStateChanged(AudioObjectID propertyID,
 
             case PDMAUDIODIR_OUT:
             {
-                PCOREAUDIOSTREAMOUT pStreamOut = pCbCtx->pOut;
+                PCOREAUDIOSTREAMOUT pStreamOut = pCAStream->pOut;
 
                 /* We move the reinitialization to the next output event.
                  * This make sure this thread isn't blocked and the
@@ -702,9 +781,9 @@ static OSStatus drvHostCoreAudioDeviceStateChanged(AudioObjectID propertyID,
         }
     }
 
-    int rc2 = coreAudioDevicesEnumerate(pCbCtx->pThis, NULL /* pCfg */, false /* fIn */, 0 /* fEnum */);
+    int rc2 = coreAudioDevicesEnumerate(pCAStream->pThis, NULL /* pCfg */, false /* fIn */, 0 /* fEnum */);
     AssertRC(rc2);
-    rc2 = coreAudioDevicesEnumerate(pCbCtx->pThis, NULL /* pCfg */, true /* fIn */, 0 /* fEnum */);
+    rc2 = coreAudioDevicesEnumerate(pCAStream->pThis, NULL /* pCfg */, true /* fIn */, 0 /* fEnum */);
     AssertRC(rc2);
 
     return noErr;
@@ -723,8 +802,8 @@ static OSStatus coreAudioDefaultDeviceChanged(AudioObjectID propertyID,
     RT_NOREF(propertyID);
     LogFlowFunc(("propertyID=%u cAddresses=%u pvUser=%p\n", propertyID, cAddresses, pvUser));
 
-    PCOREAUDIOSTREAMCBCTX pCbCtx = (PCOREAUDIOSTREAMCBCTX)pvUser;
-    AssertPtr(pCbCtx);
+    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser;
+    AssertPtr(pCAStream);
 
     OSStatus err = noErr;
     for (UInt32 idxAddress = 0; idxAddress < cAddresses; idxAddress++)
@@ -735,7 +814,7 @@ static OSStatus coreAudioDefaultDeviceChanged(AudioObjectID propertyID,
         {
             case kAudioHardwarePropertyDefaultInputDevice:
             {
-                PCOREAUDIOSTREAMIN pStreamIn = pCbCtx->pIn;
+                PCOREAUDIOSTREAMIN pStreamIn = pCAStream->pIn;
                 AssertPtr(pStreamIn);
 
                 /* This listener is called on every change of the hardware
@@ -761,7 +840,7 @@ static OSStatus coreAudioDefaultDeviceChanged(AudioObjectID propertyID,
 
             case kAudioHardwarePropertyDefaultOutputDevice:
             {
-                PCOREAUDIOSTREAMOUT pStreamOut = pCbCtx->pOut;
+                PCOREAUDIOSTREAMOUT pStreamOut = pCAStream->pOut;
                 AssertPtr(pStreamOut);
 
                 /* This listener is called on every change of the hardware
@@ -793,9 +872,9 @@ static OSStatus coreAudioDefaultDeviceChanged(AudioObjectID propertyID,
         }
     }
 
-    int rc2 = coreAudioDevicesEnumerate(pCbCtx->pThis, NULL /* pCfg */, false /* fIn */, 0 /* fEnum */);
+    int rc2 = coreAudioDevicesEnumerate(pCAStream->pThis, NULL /* pCfg */, false /* fIn */, 0 /* fEnum */);
     AssertRC(rc2);
-    rc2 = coreAudioDevicesEnumerate(pCbCtx->pThis, NULL /* pCfg */, true /* fIn */, 0 /* fEnum */);
+    rc2 = coreAudioDevicesEnumerate(pCAStream->pThis, NULL /* pCfg */, true /* fIn */, 0 /* fEnum */);
     AssertRC(rc2);
 
     /** @todo Implement callback notification here to let the audio connector / device emulation
@@ -804,7 +883,524 @@ static OSStatus coreAudioDefaultDeviceChanged(AudioObjectID propertyID,
     return noErr;
 }
 
-
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+/**
+ * Thread for a Core Audio stream's audio queue handling.
+ * This thread is required per audio queue to pump data to/from the Core Audio stream and
+ * handling its callbacks.
+ *
+ * @returns IPRT status code.
+ * @param   hThreadSelf         Thread handle.
+ * @param   pvUser              User argument.
+ */
+static DECLCALLBACK(int) coreAudioQueueThread(RTTHREAD hThreadSelf, void *pvUser)
+{
+    NOREF(hThreadSelf);
+
+    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser;
+    AssertPtr(pCAStream);
+
+    LogFunc(("Starting pCAStream=%p\n", pCAStream));
+
+    /*
+     * Create audio queue.
+     */
+    OSStatus err;
+    if (pCAStream->enmDir == PDMAUDIODIR_IN)
+        err = AudioQueueNewInput(&pCAStream->asbdStream, coreAudioInputQueueCb, pCAStream /* pvData */,
+                                 CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 0, &pCAStream->audioQueue);
+    else
+        err = AudioQueueNewOutput(&pCAStream->asbdStream, coreAudioOutputQueueCb, pCAStream /* pvData */,
+                                  CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 0, &pCAStream->audioQueue);
+
+    if (err != noErr)
+        return VERR_GENERAL_FAILURE; /** @todo Fudge! */
+
+    /*
+     * Assign device to queue.
+     */
+    UInt32 uSize = sizeof(pCAStream->UUID);
+    err = AudioQueueSetProperty(pCAStream->audioQueue, kAudioQueueProperty_CurrentDevice, &pCAStream->UUID, uSize);
+    if (err != noErr)
+        return VERR_GENERAL_FAILURE; /** @todo Fudge! */
+
+    const size_t cbBufSize = _4K; /** @todo Make this configurable! */
+
+    /*
+     * Allocate audio buffers.
+     */
+    for (size_t i = 0; i < RT_ELEMENTS(pCAStream->audioBuffer); i++)
+    {
+        err = AudioQueueAllocateBuffer(pCAStream->audioQueue, cbBufSize, &pCAStream->audioBuffer[i]);
+        if (err != noErr)
+            break;
+    }
+
+    if (err != noErr)
+        return VERR_GENERAL_FAILURE; /** @todo Fudge! */
+
+    /* Signal the main thread before entering the main loop. */
+    RTThreadUserSignal(RTThreadSelf());
+
+    /*
+     * Enter the main loop.
+     */
+    const bool fIn = pCAStream->enmDir == PDMAUDIODIR_IN;
+
+    while (!ASMAtomicReadBool(&pCAStream->fShutdown))
+    {
+        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1);
+    }
+
+    /*
+     * Cleanup.
+     */
+    if (fIn)
+    {
+        AudioQueueStop(pCAStream->audioQueue, 1);
+    }
+    else
+    {
+        AudioQueueStop(pCAStream->audioQueue, 0);
+    }
+
+    for (size_t i = 0; i < RT_ELEMENTS(pCAStream->audioBuffer); i++)
+    {
+        if (pCAStream->audioBuffer[i])
+            AudioQueueFreeBuffer(pCAStream->audioQueue, pCAStream->audioBuffer[i]);
+    }
+
+    AudioQueueDispose(pCAStream->audioQueue, 1);
+
+    LogFunc(("Ended pCAStream=%p\n", pCAStream));
+    return VINF_SUCCESS;
+}
+
+/**
+ * Processes input data of an audio queue buffer and stores it into a Core Audio stream.
+ *
+ * @returns IPRT status code.
+ * @param   pCAStream           Core Audio stream to store input data into.
+ * @param   audioBuffer         Audio buffer to process input data from.
+ */
+int coreAudioInputQueueProcBuffer(PCOREAUDIOSTREAM pCAStream, AudioQueueBufferRef audioBuffer)
+{
+    PRTCIRCBUF pCircBuf = pCAStream->pCircBuf;
+    AssertPtr(pCircBuf);
+
+    UInt8 *pvSrc = (UInt8 *)audioBuffer->mAudioData;
+    UInt8 *pvDst = NULL;
+
+    size_t cbWritten = 0;
+
+    size_t cbToWrite = audioBuffer->mAudioDataByteSize;
+    size_t cbLeft    = cbToWrite;
+
+    while (cbLeft)
+    {
+        /* Try to acquire the necessary block from the ring buffer. */
+        RTCircBufAcquireWriteBlock(pCircBuf, cbLeft, (void **)&pvDst, &cbToWrite);
+
+        if (!cbToWrite)
+            break;
+
+        /* Copy the data from our ring buffer to the core audio buffer. */
+        memcpy((UInt8 *)pvDst + cbWritten, pvSrc + cbWritten, cbToWrite);
+
+        /* Release the read buffer, so it could be used for new data. */
+        RTCircBufReleaseWriteBlock(pCircBuf, cbToWrite);
+
+        cbWritten += cbToWrite;
+
+        Assert(cbLeft >= cbToWrite);
+        cbLeft -= cbToWrite;
+    }
+
+    Log3Func(("pCAStream=%p, cbBuffer=%RU32/%zu, cbWritten=%zu\n",
+              pCAStream, audioBuffer->mAudioDataByteSize, audioBuffer->mAudioDataBytesCapacity, cbWritten));
+
+    return VINF_SUCCESS;
+}
+
+/**
+ * Input audio queue callback. Called whenever input data from the audio queue becomes available.
+ *
+ * @param   pvUser              User argument.
+ * @param   audioQueue          Audio queue to process input data from.
+ * @param   audioBuffer         Audio buffer to process input data from. Must be part of audio queue.
+ * @param   pAudioTS            Audio timestamp.
+ * @param   cPacketDesc         Number of packet descriptors.
+ * @param   paPacketDesc        Array of packet descriptors.
+ */
+static DECLCALLBACK(void) coreAudioInputQueueCb(void *pvUser, AudioQueueRef audioQueue, AudioQueueBufferRef audioBuffer,
+                                                const AudioTimeStamp *pAudioTS,
+                                                UInt32 cPacketDesc, const AudioStreamPacketDescription *paPacketDesc)
+{
+    NOREF(pAudioTS);
+    NOREF(cPacketDesc);
+    NOREF(paPacketDesc);
+
+    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser;
+    AssertPtr(pCAStream);
+
+    int rc = RTCritSectEnter(&pCAStream->CritSect);
+    AssertRC(rc);
+
+    rc = coreAudioInputQueueProcBuffer(pCAStream, audioBuffer);
+    if (RT_SUCCESS(rc))
+        AudioQueueEnqueueBuffer(audioQueue, audioBuffer, 0, NULL);
+
+    rc = RTCritSectLeave(&pCAStream->CritSect);
+    AssertRC(rc);
+}
+
+/**
+ * Processes output data of a Core Audio stream into an audio queue buffer.
+ *
+ * @returns IPRT status code.
+ * @param   pCAStream           Core Audio stream to process output data for.
+ * @param   audioBuffer         Audio buffer to store data into.
+ */
+int coreAudioOutputQueueProcBuffer(PCOREAUDIOSTREAM pCAStream, AudioQueueBufferRef audioBuffer)
+{
+    PRTCIRCBUF pCircBuf = pCAStream->pCircBuf;
+    AssertPtr(pCircBuf);
+
+    size_t cbRead = 0;
+
+    UInt8 *pvSrc = NULL;
+    UInt8 *pvDst = (UInt8 *)audioBuffer->mAudioData;
+
+    size_t cbToRead = RT_MIN(RTCircBufUsed(pCircBuf), audioBuffer->mAudioDataBytesCapacity);
+    size_t cbLeft   = cbToRead;
+
+    while (cbLeft)
+    {
+        /* Try to acquire the necessary block from the ring buffer. */
+        RTCircBufAcquireReadBlock(pCircBuf, cbLeft, (void **)&pvSrc, &cbToRead);
+
+        if (cbToRead)
+        {
+            /* Copy the data from our ring buffer to the core audio buffer. */
+            memcpy((UInt8 *)pvDst + cbRead, pvSrc, cbToRead);
+        }
+
+        /* Release the read buffer, so it could be used for new data. */
+        RTCircBufReleaseReadBlock(pCircBuf, cbToRead);
+
+        if (!cbToRead)
+            break;
+
+        /* Move offset. */
+        cbRead += cbToRead;
+        Assert(cbRead <= audioBuffer->mAudioDataBytesCapacity);
+
+        Assert(cbToRead <= cbLeft);
+        cbLeft -= cbToRead;
+    }
+
+    audioBuffer->mAudioDataByteSize = cbRead;
+
+    if (audioBuffer->mAudioDataByteSize < audioBuffer->mAudioDataBytesCapacity)
+    {
+        RT_BZERO((UInt8 *)audioBuffer->mAudioData + audioBuffer->mAudioDataByteSize,
+                 audioBuffer->mAudioDataBytesCapacity - audioBuffer->mAudioDataByteSize);
+
+        audioBuffer->mAudioDataByteSize = audioBuffer->mAudioDataBytesCapacity;
+    }
+
+    Log3Func(("pCAStream=%p, cbCapacity=%RU32, cbRead=%zu\n",
+              pCAStream, audioBuffer->mAudioDataBytesCapacity, cbRead));
+
+    return VINF_SUCCESS;
+}
+
+/**
+ * Output audio queue callback. Called whenever an audio queue is ready to process more output data.
+ *
+ * @param   pvUser              User argument.
+ * @param   audioQueue          Audio queue to process output data for.
+ * @param   audioBuffer         Audio buffer to store output data in. Must be part of audio queue.
+ */
+static DECLCALLBACK(void) coreAudioOutputQueueCb(void *pvUser, AudioQueueRef audioQueue, AudioQueueBufferRef audioBuffer)
+{
+    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser;
+    AssertPtr(pCAStream);
+
+    int rc = RTCritSectEnter(&pCAStream->CritSect);
+    AssertRC(rc);
+
+    rc = coreAudioOutputQueueProcBuffer(pCAStream, audioBuffer);
+    if (RT_SUCCESS(rc))
+        AudioQueueEnqueueBuffer(audioQueue, audioBuffer, 0, NULL);
+
+    rc = RTCritSectLeave(&pCAStream->CritSect);
+    AssertRC(rc);
+}
+
+/**
+ * Invalidates a Core Audio stream's audio queue.
+ *
+ * @returns IPRT status code.
+ * @param   pCAStream           Core Audio stream to invalidate its queue for.
+ */
+static int coreAudioStreamInvalidateQueue(PCOREAUDIOSTREAM pCAStream)
+{
+    int rc = VINF_SUCCESS;
+
+    for (size_t i = 0; i < RT_ELEMENTS(pCAStream->audioBuffer); i++)
+    {
+        AudioQueueBufferRef pBuf = pCAStream->audioBuffer[i];
+
+        if (pCAStream->enmDir == PDMAUDIODIR_IN)
+        {
+            int rc2 = coreAudioInputQueueProcBuffer(pCAStream, pBuf);
+            if (RT_SUCCESS(rc2))
+            {
+                AudioQueueEnqueueBuffer(pCAStream->audioQueue, pBuf, 0, NULL);
+            }
+        }
+        else if (pCAStream->enmDir == PDMAUDIODIR_OUT)
+        {
+            int rc2 = coreAudioOutputQueueProcBuffer(pCAStream, pBuf);
+            if (   RT_SUCCESS(rc2)
+                && pBuf->mAudioDataByteSize)
+            {
+                AudioQueueEnqueueBuffer(pCAStream->audioQueue, pBuf, 0, NULL);
+            }
+
+            if (RT_SUCCESS(rc))
+                rc = rc2;
+        }
+        else
+            AssertFailed();
+    }
+
+    return rc;
+}
+
+/**
+ * Initializes a Core Audio stream's audio queue.
+ *
+ * @returns IPRT status code.
+ * @param   pCAStream           Core Audio stream to initialize audio queue for.
+ * @param   fIn                 Whether this is an input or output queue.
+ * @param   pCfgReq             Requested stream configuration.
+ * @param   pCfgAcq             Acquired stream configuration on success.
+ */
+static int coreAudioStreamInitQueue(PCOREAUDIOSTREAM pCAStream, bool fIn, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
+{
+    RT_NOREF(pCfgAcq);
+
+    LogFunc(("pCAStream=%p, pCfgReq=%p, pCfgAcq=%p\n", pCAStream, pCfgReq, pCfgAcq));
+
+    AudioDeviceID deviceID = kAudioDeviceUnknown;
+
+    /* Fetch the default audio device currently in use. */
+    AudioObjectPropertyAddress propAdrDefaultDev = {   fIn
+                                                     ? kAudioHardwarePropertyDefaultInputDevice
+                                                     : kAudioHardwarePropertyDefaultOutputDevice,
+                                                     kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+    UInt32 uSize = sizeof(deviceID);
+    OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propAdrDefaultDev, 0, NULL, &uSize, &deviceID);
+    if (err != noErr)
+    {
+        LogRel(("CoreAudio: Unable to determine default %s device (%RI32)\n",
+                fIn ? "capturing" : "playback", err));
+        return VERR_NOT_FOUND;
+    }
+
+    /* Get the device UUID. */
+    AudioObjectPropertyAddress propAdrDevUUID = { kAudioDevicePropertyDeviceUID,
+                                                  fIn ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
+                                                  kAudioObjectPropertyElementMaster };
+    uSize = sizeof(pCAStream->UUID);
+    err = AudioObjectGetPropertyData(deviceID, &propAdrDevUUID, 0, NULL, &uSize, &pCAStream->UUID);
+    if (err != noErr)
+    {
+        LogRel(("CoreAudio: Failed to retrieve device UUID for device %RU32 (%RI32)\n", deviceID, err));
+        return VERR_NOT_FOUND;
+    }
+
+    /* Create the recording device's out format based on our required audio settings. */
+    int rc = coreAudioStreamCfgToASBD(pCfgReq, &pCAStream->asbdStream);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("CoreAudio: Failed to convert requested %s format to native format (%Rrc)\n",
+                fIn ? "input" : "output", rc));
+        return rc;
+    }
+
+    pCAStream->enmDir = fIn ? PDMAUDIODIR_IN : PDMAUDIODIR_OUT;
+
+    /* Assign device ID. */
+    if (fIn)
+    {
+        AssertPtr(pCAStream->pIn);
+        pCAStream->pIn->deviceID = deviceID;
+    }
+    else
+    {
+        AssertPtr(pCAStream->pOut);
+        pCAStream->pOut->deviceID = deviceID;
+    }
+
+    coreAudioPrintASBD(  fIn
+                       ? "Capturing queue format"
+                       : "Playback queue format", &pCAStream->asbdStream);
+
+    rc = RTCircBufCreate(&pCAStream->pCircBuf, 8096 << 1 /*pHstStrmIn->Props.cShift*/); /** @todo FIX THIS !!! */
+    if (RT_FAILURE(rc))
+        return rc;
+
+    /*
+     * Start the thread.
+     */
+    rc = RTThreadCreate(&pCAStream->hThread, coreAudioQueueThread,
+                        pCAStream /* pvUser */, 0 /* Default stack size */,
+                        RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "CAQUEUE");
+    if (RT_SUCCESS(rc))
+        rc = RTThreadUserWait(pCAStream->hThread, 10 * 1000 /* 10s timeout */);
+
+    LogFunc(("Returning %Rrc\n", rc));
+    return rc;
+}
+
+/**
+ * Unitializes a Core Audio stream's audio queue.
+ *
+ * @returns IPRT status code.
+ * @param   pCAStream           Core Audio stream to unitialize audio queue for.
+ */
+static int coreAudioStreamUninitQueue(PCOREAUDIOSTREAM pCAStream)
+{
+    LogFunc(("pCAStream=%p\n", pCAStream));
+
+    int rc;
+
+    if (pCAStream->hThread != NIL_RTTHREAD)
+    {
+        LogFunc(("Waiting for thread ...\n"));
+
+        ASMAtomicXchgBool(&pCAStream->fShutdown, true);
+
+        int rcThread;
+        rc = RTThreadWait(pCAStream->hThread, 30 * 1000, &rcThread);
+        if (RT_FAILURE(rc))
+            return rc;
+
+        NOREF(rcThread);
+        LogFunc(("Thread stopped with %Rrc\n", rcThread));
+
+        pCAStream->hThread = NIL_RTTHREAD;
+    }
+
+    if (pCAStream->pCircBuf)
+    {
+        RTCircBufDestroy(pCAStream->pCircBuf);
+        pCAStream->pCircBuf = NULL;
+    }
+
+    LogFunc(("Returning\n"));
+    return VINF_SUCCESS;
+}
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
+
+/**
+ * Unitializes a Core Audio stream.
+ *
+ * @returns IPRT status code.
+ * @param   pCAStream           Core Audio stream to uninitialize.
+ */
+static int coreAudioStreamUninit(PCOREAUDIOSTREAM pCAStream)
+{
+    LogFunc(("pCAStream=%p\n", pCAStream));
+
+    int rc;
+
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = coreAudioStreamUninitQueue(pCAStream);
+#else
+    rc = VINF_SUCCESS;
+#endif
+
+    return rc;
+}
+
+static int coreAudioStreamReinitIn(PCOREAUDIOSTREAM pCAStream)
+{
+    int rc = coreAudioStreamUninit(pCAStream);
+    if (RT_SUCCESS(rc))
+    {
+        PDMAUDIOSTREAMCFG CfgAcq;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+        rc = coreAudioASBDToStreamCfg(&pCAStream->asbdStream, &CfgAcq);
+#else
+        rc = coreAudioASBDToStreamCfg(&pCAStream->pIn->streamFormat, &CfgAcq);
+#endif
+        if (RT_SUCCESS(rc))
+        {
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+            rc = coreAudioStreamInitQueue(pCAStream, true /* fInput */, &CfgAcq /* pCfgReq */, NULL /* pCfgAcq */);
+#else
+            /* Use the acquired stream configuration from the former initialization to
+             * re-initialize the stream. */
+            rc = coreAudioStreamInitIn(pCAStream->pIn, &CfgAcq /* pCfgReq */, NULL /* pCfgAcq */);
+#endif
+            if (RT_SUCCESS(rc))
+                rc = coreAudioControlStreamIn(pCAStream->pIn, PDMAUDIOSTREAMCMD_ENABLE);
+
+            if (RT_FAILURE(rc))
+            {
+                int rc2 = coreAudioStreamUninit(pCAStream);
+                AssertRC(rc2);
+            }
+        }
+    }
+
+    if (RT_FAILURE(rc))
+        LogRel(("CoreAudio: Unable to re-init input stream: %Rrc\n", rc));
+
+    return rc;
+}
+
+static int coreAudioStreamReinitOut(PCOREAUDIOSTREAM pCAStream)
+{
+    int rc = coreAudioStreamUninit(pCAStream);
+    if (RT_SUCCESS(rc))
+    {
+        PDMAUDIOSTREAMCFG CfgAcq;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+        rc = coreAudioASBDToStreamCfg(&pCAStream->asbdStream, &CfgAcq);
+#else
+        rc = coreAudioASBDToStreamCfg(&pCAStream->pOut->streamFormat, &CfgAcq);
+#endif
+        if (RT_SUCCESS(rc))
+        {
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+            rc = coreAudioStreamInitQueue(pCAStream, false /* fInput */, &CfgAcq /* pCfgReq */, NULL /* pCfgAcq */);
+#else
+            /* Use the acquired stream configuration from the former initialization to
+             * re-initialize the stream. */
+            rc = coreAudioStreamInitOut(pCAStream->pOut, &CfgAcq /* pCfgReq */, NULL /* pCfgAcq */);
+#endif
+            if (RT_SUCCESS(rc))
+                rc = coreAudioControlStreamOut(pCAStream->pOut, PDMAUDIOSTREAMCMD_ENABLE);
+
+            if (RT_FAILURE(rc))
+            {
+                int rc2 = coreAudioStreamUninit(pCAStream);
+                AssertRC(rc2);
+            }
+        }
+    }
+
+    if (RT_FAILURE(rc))
+        LogRel(("CoreAudio: Unable to re-init output stream: %Rrc\n", rc));
+
+    return rc;
+}
+
 /**
  * Implements the OS X callback AudioObjectPropertyListenerProc for getting
  * notified when some of the properties of an audio device has changed.
@@ -844,6 +1440,7 @@ static OSStatus coreAudioRecordingAudioDevicePropertyChanged(AudioObjectID
     return noErr;
 }
 
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
 /**
  * Implements the OS X callback AudioConverterComplexInputDataProc for
  * converting audio input data from one format to another.
@@ -922,7 +1519,9 @@ static OSStatus coreAudioConverterCallback(AudioConverterRef              inAudi
 
     return noErr;
 }
+#endif /* VBOX_WITH_AUDIO_CA_CONVERTER */
 
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
 /**
  * Implements the OS X callback AURenderCallback in order to feed the audio
  * input buffer.
@@ -963,6 +1562,7 @@ static OSStatus coreAudioRecordingCb(void                       *pvUser,
 
     do
     {
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
         /* Are we using a converter? */
         if (pStreamIn->pConverter)
         {
@@ -1076,6 +1676,7 @@ static OSStatus coreAudioRecordingCb(void                       *pvUser,
         }
         else /* No converter being used. */
         {
+#endif /* VBOX_WITH_AUDIO_CA_CONVERTER */
             AssertBreakStmt(pStreamIn->streamFormat.mChannelsPerFrame >= 1, rc = VERR_INVALID_PARAMETER);
             AssertBreakStmt(pStreamIn->streamFormat.mBytesPerFrame >= 1,    rc = VERR_INVALID_PARAMETER);
 
@@ -1128,7 +1729,10 @@ static OSStatus coreAudioRecordingCb(void                       *pvUser,
             }
 
             Log3Func(("cbWrittenTotal=%RU32, cbLeft=%zu\n", cbWrittenTotal, cbAvail));
+
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
         }
+#endif /* VBOX_WITH_AUDIO_CA_CONVERTER */
 
     } while (0);
 
@@ -1140,6 +1744,7 @@ static OSStatus coreAudioRecordingCb(void                       *pvUser,
 
     return err;
 }
+#endif /* !VBOX_WITH_AUDIO_CA_QUEUES */
 
 #define CA_BREAK_STMT(stmt) if (true) \
     { \
@@ -1147,15 +1752,12 @@ static OSStatus coreAudioRecordingCb(void                       *pvUser,
         break; \
     } else do { } while (0)
 
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
 /** @todo Eventually split up this function, as this already is huge! */
-static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
-                           PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
+static int coreAudioStreamInitIn(PCOREAUDIOSTREAMIN pStreamIn, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
 {
-    RT_NOREF(pThis);
-
     int rc = VINF_SUCCESS;
 
-    PCOREAUDIOSTREAMIN pStreamIn = (PCOREAUDIOSTREAMIN)pStream;
     UInt32 cSamples = 0;
 
     OSStatus err = noErr;
@@ -1184,8 +1786,6 @@ static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
 
     do
     {
-        ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_IN_INIT);
-
         /* Assign device ID. */
         pStreamIn->deviceID = deviceID;
 
@@ -1487,8 +2087,9 @@ static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
             pStreamIn->pCircBuf = NULL;
         }
 
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
         coreAudioUninitConvCbCtx(&pStreamIn->convCbCtx);
-
+#endif
         /* Calculate the ratio between the device and the stream sample rate. */
         pStreamIn->sampleRatio = pStreamIn->streamFormat.mSampleRate / pStreamIn->deviceFormat.mSampleRate;
 
@@ -1517,10 +2118,11 @@ static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
         if (RT_FAILURE(rc))
             break;
 
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
         /* Init the converter callback context. */
         rc = coreAudioInitConvCbCtx(&pStreamIn->convCbCtx,
                                     &pStreamIn->deviceFormat /* Source */, &pStreamIn->streamFormat /* Dest */);
-
+#endif
         if (RT_SUCCESS(rc))
         {
 #ifdef DEBUG
@@ -1544,8 +2146,6 @@ static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
 
     if (RT_SUCCESS(rc))
     {
-        ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_INIT);
-
         LogFunc(("cSamples=%RU32\n", cSamples));
 
         if (pCfgAcq)
@@ -1561,9 +2161,9 @@ static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
             pStreamIn->pCircBuf = NULL;
         }
 
+#ifdef VBOX_WITH_AUDIO_CA_CONVERTER
         coreAudioUninitConvCbCtx(&pStreamIn->convCbCtx);
-
-        ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_UNINIT);
+#endif
     }
 
     LogFunc(("rc=%Rrc\n", rc));
@@ -1571,14 +2171,10 @@ static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream,
 }
 
 /** @todo Eventually split up this function, as this already is huge! */
-static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis,
-                            PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
+static int coreAudioStreamInitOut(PCOREAUDIOSTREAMOUT pStreamOut, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
 {
-    RT_NOREF(pThis);
-
     int rc = VINF_SUCCESS;
 
-    PCOREAUDIOSTREAMOUT pStreamOut = (PCOREAUDIOSTREAMOUT)pStream;
     UInt32 cSamples = 0;
 
     OSStatus err = noErr;
@@ -1607,8 +2203,6 @@ static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis,
 
     do
     {
-        ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_IN_INIT);
-
         /* Assign device ID. */
         pStreamOut->deviceID = deviceID;
 
@@ -1854,8 +2448,6 @@ static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis,
 
     if (RT_SUCCESS(rc))
     {
-        ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_INIT);
-
         LogFunc(("cSamples=%RU32\n", cSamples));
 
         if (pCfgAcq)
@@ -1870,14 +2462,12 @@ static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis,
             RTCircBufDestroy(pStreamOut->pCircBuf);
             pStreamOut->pCircBuf = NULL;
         }
-
-        ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_UNINIT);
     }
 
     LogFunc(("cSamples=%RU32, rc=%Rrc\n", cSamples, rc));
     return rc;
 }
-
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
 
 /**
  * Implements the OS X callback AudioObjectPropertyListenerProc for getting
@@ -1901,7 +2491,7 @@ static OSStatus coreAudioPlaybackAudioDevicePropertyChanged(AudioObjectID proper
     return noErr;
 }
 
-
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
 /**
  * Implements the OS X callback AURenderCallback in order to feed the audio
  * output buffer.
@@ -1972,7 +2562,7 @@ static OSStatus coreAudioPlaybackCb(void *pvUser,
 
     return noErr;
 }
-
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
 
 /**
  * @interface_method_impl{PDMIHOSTAUDIO, pfnInit}
@@ -2005,11 +2595,15 @@ static DECLCALLBACK(int) drvHostCoreAudioStreamCapture(PPDMIHOSTAUDIO pInterface
     /* pcbRead is optional. */
 
     PCOREAUDIOSTREAMIN pStreamIn = (PCOREAUDIOSTREAMIN)pStream;
+    PCOREAUDIOSTREAM   pCAStream = &pStreamIn->Common;
 
-/* unused, make you wonder why...
-    size_t csReads = 0;
-    char *pcSrc;
-    PPDMAUDIOSAMPLE psDst; */
+    /* Check if the audio device should be reinitialized. If so do it. */
+    if (ASMAtomicReadU32(&pStreamIn->status) == CA_STATUS_REINIT)
+    {
+        int rc2 = coreAudioStreamReinitIn(pCAStream);
+        if (RT_FAILURE(rc2))
+            return VERR_NOT_AVAILABLE;
+    }
 
     if (ASMAtomicReadU32(&pStreamIn->status) != CA_STATUS_INIT)
     {
@@ -2021,65 +2615,79 @@ static DECLCALLBACK(int) drvHostCoreAudioStreamCapture(PPDMIHOSTAUDIO pInterface
     int rc = VINF_SUCCESS;
     uint32_t cbWrittenTotal = 0;
 
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = RTCritSectEnter(&pCAStream->CritSect);
+    AssertRC(rc);
+#endif
+
+    PRTCIRCBUF pCircBuf = NULL;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    pCircBuf = pCAStream->pCircBuf;
+#else
+    pCircBuf = pStreamIn->pCircBuf;
+#endif
+    AssertPtr(pCircBuf);
+
     do
     {
         size_t cbMixBuf  = AudioMixBufSizeBytes(&pStream->MixBuf);
-        size_t cbToWrite = RT_MIN(cbMixBuf, RTCircBufUsed(pStreamIn->pCircBuf));
+        size_t cbToWrite = RT_MIN(cbMixBuf, RTCircBufUsed(pCircBuf));
 
         uint32_t cWritten, cbWritten;
-        uint8_t *puBuf;
-        size_t   cbToRead;
 
-        Log3Func(("cbMixBuf=%zu, cbToWrite=%zu/%zu\n", cbMixBuf, cbToWrite, RTCircBufSize(pStreamIn->pCircBuf)));
+        uint8_t *pvChunk;
+        size_t   cbChunk;
+
+        Log3Func(("cbMixBuf=%zu, cbToWrite=%zu/%zu\n", cbMixBuf, cbToWrite, RTCircBufSize(pCircBuf)));
 
         while (cbToWrite)
         {
             /* Try to acquire the necessary block from the ring buffer. */
-            RTCircBufAcquireReadBlock(pStreamIn->pCircBuf, cbToWrite, (void **)&puBuf, &cbToRead);
-            if (!cbToRead)
+            RTCircBufAcquireReadBlock(pCircBuf, cbToWrite, (void **)&pvChunk, &cbChunk);
+            if (cbChunk)
             {
-                RTCircBufReleaseReadBlock(pStreamIn->pCircBuf, cbToRead);
-                break;
-            }
-
 #ifdef DEBUG_DUMP_PCM_DATA
-            RTFILE fh;
-            rc = RTFileOpen(&fh, DEBUG_DUMP_PCM_DATA_PATH "ca-capture.pcm",
-                            RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
-            if (RT_SUCCESS(rc))
-            {
-                RTFileWrite(fh, puBuf + cbWrittenTotal, cbToRead, NULL);
-                RTFileClose(fh);
-            }
-            else
-                AssertFailed();
+                RTFILE fh;
+                rc = RTFileOpen(&fh, DEBUG_DUMP_PCM_DATA_PATH "ca-capture.pcm",
+                                RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
+                if (RT_SUCCESS(rc))
+                {
+                    RTFileWrite(fh, pvChunk, cbChunk, NULL);
+                    RTFileClose(fh);
+                }
+                else
+                    AssertFailed();
 #endif
-            rc = AudioMixBufWriteCirc(&pStream->MixBuf, puBuf, cbToRead, &cWritten);
+                rc = AudioMixBufWriteCirc(&pStream->MixBuf, pvChunk, cbChunk, &cWritten);
+                if (rc == VERR_BUFFER_OVERFLOW)
+                {
+                    LogRel2(("Core Audio: Capturing host buffer full\n"));
+                    rc = VINF_SUCCESS;
+                }
+            }
 
             /* Release the read buffer, so it could be used for new data. */
-            RTCircBufReleaseReadBlock(pStreamIn->pCircBuf, cbToRead);
+            RTCircBufReleaseReadBlock(pCircBuf, cbChunk);
 
-            if (   RT_FAILURE(rc)
-                || !cWritten)
-            {
-                RTCircBufReleaseReadBlock(pStreamIn->pCircBuf, cbToRead);
+            if (RT_FAILURE(rc))
                 break;
-            }
 
             cbWritten = AUDIOMIXBUF_S2B(&pStream->MixBuf, cWritten);
 
-            /* Release the read buffer, so it could be used for new data. */
-            RTCircBufReleaseReadBlock(pStreamIn->pCircBuf, cbWritten);
-
             Assert(cbToWrite >= cbWritten);
             cbToWrite      -= cbWritten;
             cbWrittenTotal += cbWritten;
         }
 
-        Log3Func(("cbToWrite=%zu, cbToRead=%zu, cbWrittenTotal=%RU32, rc=%Rrc\n", cbToWrite, cbToRead, cbWrittenTotal, rc));
+        Log3Func(("cbToWrite=%zu, cbToRead=%zu, cbWrittenTotal=%RU32, rc=%Rrc\n", cbToWrite, cbChunk, cbWrittenTotal, rc));
     }
     while (0);
 
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    int rc2 = RTCritSectLeave(&pCAStream->CritSect);
+    AssertRC(rc2);
+#endif
+
     if (RT_SUCCESS(rc))
     {
         uint32_t cCaptured     = 0;
@@ -2116,6 +2724,23 @@ static DECLCALLBACK(int) drvHostCoreAudioStreamPlay(PPDMIHOSTAUDIO pInterface,
     /* pcbWritten is optional. */
 
     PCOREAUDIOSTREAMOUT pStreamOut = (PCOREAUDIOSTREAMOUT)pStream;
+    PCOREAUDIOSTREAM    pCAStream  = &pStreamOut->Common;
+
+    /* Check if the audio device should be reinitialized. If so do it. */
+    if (ASMAtomicReadU32(&pStreamOut->status) == CA_STATUS_REINIT)
+    {
+        /* For now re just re-initialize with the current output device. */
+        int rc2 = coreAudioStreamReinitOut(pCAStream);
+        if (RT_FAILURE(rc2))
+            return VERR_NOT_AVAILABLE;
+    }
+
+    if (ASMAtomicReadU32(&pStreamOut->status) != CA_STATUS_INIT)
+    {
+        if (pcbWritten)
+            *pcbWritten = 0;
+        return VINF_SUCCESS;
+    }
 
     int rc = VINF_SUCCESS;
 
@@ -2131,45 +2756,72 @@ static DECLCALLBACK(int) drvHostCoreAudioStreamPlay(PPDMIHOSTAUDIO pInterface,
 
     uint32_t cbReadTotal = 0;
 
-    size_t cbToRead = RT_MIN(cbLive, RTCircBufFree(pStreamOut->pCircBuf));
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = RTCritSectEnter(&pCAStream->CritSect);
+    AssertRC(rc);
+#endif
+
+    PRTCIRCBUF pCircBuf = NULL;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    pCircBuf = pCAStream->pCircBuf;
+#else
+    pCircBuf = pStreamOut->pCircBuf;
+#endif
+    AssertPtr(pCircBuf);
+
+    size_t cbToRead = RT_MIN(cbLive, RTCircBufFree(pCircBuf));
     Log3Func(("cbToRead=%zu\n", cbToRead));
 
+    uint8_t *pvChunk;
+    size_t   cbChunk;
+
     while (cbToRead)
     {
         uint32_t cRead, cbRead;
-        uint8_t *puBuf;
-        size_t   cbCopy;
 
         /* Try to acquire the necessary space from the ring buffer. */
-        RTCircBufAcquireWriteBlock(pStreamOut->pCircBuf, cbToRead, (void **)&puBuf, &cbCopy);
-        if (!cbCopy)
+        RTCircBufAcquireWriteBlock(pCircBuf, cbToRead, (void **)&pvChunk, &cbChunk);
+        if (!cbChunk)
         {
-            RTCircBufReleaseWriteBlock(pStreamOut->pCircBuf, cbCopy);
+            RTCircBufReleaseWriteBlock(pCircBuf, cbChunk);
             break;
         }
 
-        Assert(cbCopy <= cbToRead);
+        Assert(cbChunk <= cbToRead);
 
-        rc = AudioMixBufReadCirc(&pStream->MixBuf,
-                                 puBuf, cbCopy, &cRead);
-
-        if (   RT_FAILURE(rc)
-            || !cRead)
-        {
-            RTCircBufReleaseWriteBlock(pStreamOut->pCircBuf, 0);
-            break;
-        }
+        rc = AudioMixBufReadCirc(&pStream->MixBuf, pvChunk, cbChunk, &cRead);
 
         cbRead = AUDIOMIXBUF_S2B(&pStream->MixBuf, cRead);
 
         /* Release the ring buffer, so the read thread could start reading this data. */
-        RTCircBufReleaseWriteBlock(pStreamOut->pCircBuf, cbRead);
+        RTCircBufReleaseWriteBlock(pCircBuf, cbChunk);
+
+        if (RT_FAILURE(rc))
+            break;
 
         Assert(cbToRead >= cbRead);
         cbToRead -= cbRead;
         cbReadTotal += cbRead;
     }
 
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    if (    RT_SUCCESS(rc)
+        &&  pCAStream->fRun
+        && !pCAStream->fIsRunning)
+    {
+        rc = coreAudioStreamInvalidateQueue(pCAStream);
+        if (RT_SUCCESS(rc))
+        {
+            AudioQueueStart(pCAStream->audioQueue, NULL);
+            pCAStream->fRun       = false;
+            pCAStream->fIsRunning = true;
+        }
+    }
+
+    int rc2 = RTCritSectLeave(&pCAStream->CritSect);
+    AssertRC(rc2);
+#endif
+
     if (RT_SUCCESS(rc))
     {
         uint32_t cReadTotal = AUDIOMIXBUF_B2S(&pStream->MixBuf, cbReadTotal);
@@ -2185,13 +2837,11 @@ static DECLCALLBACK(int) drvHostCoreAudioStreamPlay(PPDMIHOSTAUDIO pInterface,
     return rc;
 }
 
-static int coreAudioControlStreamOut(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
+static int coreAudioControlStreamOut(PCOREAUDIOSTREAMOUT pCAStreamOut, PDMAUDIOSTREAMCMD enmStreamCmd)
 {
-    PCOREAUDIOSTREAMOUT pStreamOut = (PCOREAUDIOSTREAMOUT)pStream;
-
     LogFlowFunc(("enmStreamCmd=%RU32\n", enmStreamCmd));
 
-    uint32_t uStatus = ASMAtomicReadU32(&pStreamOut->status);
+    uint32_t uStatus = ASMAtomicReadU32(&pCAStreamOut->status);
     if (!(   uStatus == CA_STATUS_INIT
           || uStatus == CA_STATUS_REINIT))
     {
@@ -2200,40 +2850,76 @@ static int coreAudioControlStreamOut(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD
 
     int rc = VINF_SUCCESS;
 
-    OSStatus err;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    PCOREAUDIOSTREAM pCAStream = &pCAStreamOut->Common;
+#endif
+
     switch (enmStreamCmd)
     {
         case PDMAUDIOSTREAMCMD_ENABLE:
         case PDMAUDIOSTREAMCMD_RESUME:
         {
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+            LogFunc(("Queue enable\n"));
+            if (pCAStream->enmDir == PDMAUDIODIR_IN)
+            {
+                rc = coreAudioStreamInvalidateQueue(pCAStream);
+                if (RT_SUCCESS(rc))
+                {
+                    /* Start the audio queue immediately. */
+                    AudioQueueStart(pCAStream->audioQueue, NULL);
+                }
+            }
+            if (pCAStream->enmDir == PDMAUDIODIR_OUT)
+            {
+                /* Touch the run flag to start the audio queue as soon as
+                 * we have anough data to actually play something. */
+                ASMAtomicXchgBool(&pCAStream->fRun, true);
+            }
+#else
             /* Only start the device if it is actually stopped */
-            if (!coreAudioIsRunning(pStreamOut->deviceID))
+            if (!coreAudioIsRunning(pCAStreamOut->deviceID))
             {
-                err = AudioUnitReset(pStreamOut->audioUnit, kAudioUnitScope_Input, 0);
+                OSStatus err = AudioUnitReset(pCAStreamOut->audioUnit, kAudioUnitScope_Input, 0);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to reset AudioUnit (%RI32)\n", err));
                     /* Keep going. */
                 }
-                RTCircBufReset(pStreamOut->pCircBuf);
+                RTCircBufReset(pCAStreamOut->pCircBuf);
 
-                err = AudioOutputUnitStart(pStreamOut->audioUnit);
+                err = AudioOutputUnitStart(pCAStreamOut->audioUnit);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to start playback (%RI32)\n", err));
                     rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
                 }
             }
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
             break;
         }
 
         case PDMAUDIOSTREAMCMD_DISABLE:
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+        {
+            LogFunc(("Queue disable\n"));
+            AudioQueueStop(pCAStream->audioQueue, 1 /* Immediately */);
+            ASMAtomicXchgBool(&pCAStream->fRun,       false);
+            ASMAtomicXchgBool(&pCAStream->fIsRunning, false);
+            break;
+        }
+#endif
         case PDMAUDIOSTREAMCMD_PAUSE:
         {
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+            LogFunc(("Queue pause\n"));
+            AudioQueuePause(pCAStream->audioQueue);
+            ASMAtomicXchgBool(&pCAStream->fIsRunning, false);
+#else
             /* Only stop the device if it is actually running */
-            if (coreAudioIsRunning(pStreamOut->deviceID))
+            if (coreAudioIsRunning(pCAStreamOut->deviceID))
             {
-                err = AudioOutputUnitStop(pStreamOut->audioUnit);
+                OSStatus err = AudioOutputUnitStop(pCAStreamOut->audioUnit);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to stop playback (%RI32)\n", err));
@@ -2241,13 +2927,14 @@ static int coreAudioControlStreamOut(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD
                     break;
                 }
 
-                err = AudioUnitReset(pStreamOut->audioUnit, kAudioUnitScope_Input, 0);
+                err = AudioUnitReset(pCAStreamOut->audioUnit, kAudioUnitScope_Input, 0);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to reset AudioUnit (%RI32)\n", err));
                     rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
                 }
             }
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
             break;
         }
 
@@ -2260,13 +2947,11 @@ static int coreAudioControlStreamOut(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD
     return rc;
 }
 
-static int coreAudioControlStreamIn(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
+static int coreAudioControlStreamIn(PCOREAUDIOSTREAMIN pCAStreamIn, PDMAUDIOSTREAMCMD enmStreamCmd)
 {
-    PCOREAUDIOSTREAMIN pStreamIn = (PCOREAUDIOSTREAMIN)pStream;
-
     LogFlowFunc(("enmStreamCmd=%RU32\n", enmStreamCmd));
 
-    uint32_t uStatus = ASMAtomicReadU32(&pStreamIn->status);
+    uint32_t uStatus = ASMAtomicReadU32(&pCAStreamIn->status);
     if (!(   uStatus == CA_STATUS_INIT
           || uStatus == CA_STATUS_REINIT))
     {
@@ -2275,17 +2960,38 @@ static int coreAudioControlStreamIn(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD e
 
     int rc = VINF_SUCCESS;
 
-    OSStatus err;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    PCOREAUDIOSTREAM pCAStream = &pCAStreamIn->Common;
+#endif
+
     switch (enmStreamCmd)
     {
         case PDMAUDIOSTREAMCMD_ENABLE:
         case PDMAUDIOSTREAMCMD_RESUME:
         {
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+            LogFunc(("Queue enable\n"));
+            if (pCAStream->enmDir == PDMAUDIODIR_IN)
+            {
+                rc = coreAudioStreamInvalidateQueue(pCAStream);
+                if (RT_SUCCESS(rc))
+                {
+                    /* Start the audio queue immediately. */
+                    AudioQueueStart(pCAStream->audioQueue, NULL);
+                }
+            }
+            if (pCAStream->enmDir == PDMAUDIODIR_OUT)
+            {
+                /* Touch the run flag to start the audio queue as soon as
+                 * we have anough data to actually play something. */
+                ASMAtomicXchgBool(&pCAStream->fRun, true);
+            }
+#else
             /* Only start the device if it is actually stopped */
-            if (!coreAudioIsRunning(pStreamIn->deviceID))
+            if (!coreAudioIsRunning(pCAStreamIn->deviceID))
             {
-                RTCircBufReset(pStreamIn->pCircBuf);
-                err = AudioOutputUnitStart(pStreamIn->audioUnit);
+                RTCircBufReset(pCAStreamIn->pCircBuf);
+                OSStatus err = AudioOutputUnitStart(pCAStreamIn->audioUnit);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to start recording (%RI32)\n", err));
@@ -2293,17 +2999,31 @@ static int coreAudioControlStreamIn(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD e
                     break;
                 }
             }
-
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
             break;
         }
 
         case PDMAUDIOSTREAMCMD_DISABLE:
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+        {
+            LogFunc(("Queue disable\n"));
+            AudioQueueStop(pCAStream->audioQueue, 1 /* Immediately */);
+            ASMAtomicXchgBool(&pCAStream->fRun,       false);
+            ASMAtomicXchgBool(&pCAStream->fIsRunning, false);
+            break;
+        }
+#endif
         case PDMAUDIOSTREAMCMD_PAUSE:
         {
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+            LogFunc(("Queue pause\n"));
+            AudioQueuePause(pCAStream->audioQueue);
+            ASMAtomicXchgBool(&pCAStream->fIsRunning, false);
+#else
             /* Only stop the device if it is actually running */
-            if (coreAudioIsRunning(pStreamIn->deviceID))
+            if (coreAudioIsRunning(pCAStreamIn->deviceID))
             {
-                err = AudioOutputUnitStop(pStreamIn->audioUnit);
+                OSStatus err = AudioOutputUnitStop(pCAStreamIn->audioUnit);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to stop recording (%RI32)\n", err));
@@ -2311,7 +3031,7 @@ static int coreAudioControlStreamIn(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD e
                     break;
                 }
 
-                err = AudioUnitReset(pStreamIn->audioUnit, kAudioUnitScope_Input, 0);
+                err = AudioUnitReset(pCAStreamIn->audioUnit, kAudioUnitScope_Input, 0);
                 if (err != noErr)
                 {
                     LogRel(("CoreAudio: Failed to reset AudioUnit (%RI32)\n", err));
@@ -2319,6 +3039,7 @@ static int coreAudioControlStreamIn(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD e
                     break;
                 }
             }
+#endif /* VBOX_WITH_AUDIO_CA_QUEUES */
             break;
         }
 
@@ -2334,6 +3055,7 @@ static int coreAudioControlStreamIn(PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD e
 static int coreAudioDestroyStreamIn(PPDMAUDIOSTREAM pStream)
 {
     PCOREAUDIOSTREAMIN pStreamIn = (PCOREAUDIOSTREAMIN)pStream;
+    PCOREAUDIOSTREAM   pCAStream = &pStreamIn->Common;
 
     LogFlowFuncEnter();
 
@@ -2346,95 +3068,107 @@ static int coreAudioDestroyStreamIn(PPDMAUDIOSTREAM pStream)
 
     OSStatus err = noErr;
 
-    int rc = coreAudioControlStreamIn(&pStreamIn->Stream, PDMAUDIOSTREAMCMD_DISABLE);
+    int rc = coreAudioControlStreamIn(pStreamIn, PDMAUDIOSTREAMCMD_DISABLE);
     if (RT_SUCCESS(rc))
     {
         ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_IN_UNINIT);
 
-        /*
-         * Unregister recording device callbacks.
-         */
-        AudioObjectPropertyAddress propAdr = { kAudioDeviceProcessorOverload, kAudioObjectPropertyScopeGlobal,
-                                               kAudioObjectPropertyElementMaster };
-#ifdef DEBUG
-        err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr,
-                                                coreAudioRecordingAudioDevicePropertyChanged, &pStreamIn->cbCtx);
-        if (   err != noErr
-            && err != kAudioHardwareBadObjectError)
-        {
-            LogRel(("CoreAudio: Failed to remove the recording processor overload listener (%RI32)\n", err));
-        }
-#endif /* DEBUG */
-
-        propAdr.mSelector = kAudioDevicePropertyNominalSampleRate;
-        err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr,
-                                                coreAudioRecordingAudioDevicePropertyChanged, &pStreamIn->cbCtx);
-        if (   err != noErr
-            && err != kAudioHardwareBadObjectError)
+        rc = coreAudioStreamUninit(pCAStream);
+        if (RT_SUCCESS(rc))
         {
-            LogRel(("CoreAudio: Failed to remove the recording sample rate changed listener (%RI32)\n", err));
-        }
+            ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_UNINIT);
 
-        if (pStreamIn->fDefDevChgListReg)
-        {
-            propAdr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-            err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &propAdr,
-                                                    coreAudioDefaultDeviceChanged, &pStreamIn->cbCtx);
+            /*
+             * Unregister recording device callbacks.
+             */
+            AudioObjectPropertyAddress propAdr = { kAudioDeviceProcessorOverload, kAudioObjectPropertyScopeGlobal,
+                                                   kAudioObjectPropertyElementMaster };
+#ifdef DEBUG
+            err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr,
+                                                    coreAudioRecordingAudioDevicePropertyChanged, &pStreamIn->Common);
             if (   err != noErr
                 && err != kAudioHardwareBadObjectError)
             {
-                LogRel(("CoreAudio: Failed to remove the default recording device changed listener (%RI32)\n", err));
+                LogRel(("CoreAudio: Failed to remove the recording processor overload listener (%RI32)\n", err));
             }
+#endif /* DEBUG */
 
-            pStreamIn->fDefDevChgListReg = false;
-        }
-
-        if (pStreamIn->fDevStateChgListReg)
-        {
-            Assert(pStreamIn->deviceID != kAudioDeviceUnknown);
-
-            AudioObjectPropertyAddress propAdr2 = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
-                                                    kAudioObjectPropertyElementMaster };
-            err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr2,
-                                                    drvHostCoreAudioDeviceStateChanged, &pStreamIn->cbCtx);
+            propAdr.mSelector = kAudioDevicePropertyNominalSampleRate;
+            err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr,
+                                                    coreAudioRecordingAudioDevicePropertyChanged, &pStreamIn->Common);
             if (   err != noErr
                 && err != kAudioHardwareBadObjectError)
             {
-                LogRel(("CoreAudio: Failed to remove the recording device state changed listener (%RI32)\n", err));
+                LogRel(("CoreAudio: Failed to remove the recording sample rate changed listener (%RI32)\n", err));
             }
 
-            pStreamIn->fDevStateChgListReg = false;
-        }
+            if (pStreamIn->fDefDevChgListReg)
+            {
+                propAdr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+                err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &propAdr,
+                                                        coreAudioDefaultDeviceChanged, &pStreamIn->Common);
+                if (   err != noErr
+                    && err != kAudioHardwareBadObjectError)
+                {
+                    LogRel(("CoreAudio: Failed to remove the default recording device changed listener (%RI32)\n", err));
+                }
 
-        if (pStreamIn->pConverter)
-        {
-            AudioConverterDispose(pStreamIn->pConverter);
-            pStreamIn->pConverter = NULL;
-        }
+                pStreamIn->fDefDevChgListReg = false;
+            }
 
-        err = AudioUnitUninitialize(pStreamIn->audioUnit);
-        if (err == noErr)
-            err = AudioComponentInstanceDispose(pStreamIn->audioUnit);
+            if (pStreamIn->fDevStateChgListReg)
+            {
+                Assert(pStreamIn->deviceID != kAudioDeviceUnknown);
 
-        if (   err != noErr
-            && err != kAudioHardwareBadObjectError)
-        {
-            LogRel(("CoreAudio: Failed to uninit the recording device (%RI32)\n", err));
-        }
+                AudioObjectPropertyAddress propAdr2 = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
+                                                        kAudioObjectPropertyElementMaster };
+                err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr2,
+                                                        drvHostCoreAudioDeviceStateChanged, &pStreamIn->Common);
+                if (   err != noErr
+                    && err != kAudioHardwareBadObjectError)
+                {
+                    LogRel(("CoreAudio: Failed to remove the recording device state changed listener (%RI32)\n", err));
+                }
 
-        pStreamIn->deviceID      = kAudioDeviceUnknown;
-        pStreamIn->audioUnit     = NULL;
-        pStreamIn->sampleRatio   = 1;
+                pStreamIn->fDevStateChgListReg = false;
+            }
 
-        coreAudioUninitConvCbCtx(&pStreamIn->convCbCtx);
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
+            if (pStreamIn->pConverter)
+            {
+                AudioConverterDispose(pStreamIn->pConverter);
+                pStreamIn->pConverter = NULL;
+            }
 
-        if (pStreamIn->pCircBuf)
-        {
-            RTCircBufDestroy(pStreamIn->pCircBuf);
-            pStreamIn->pCircBuf = NULL;
-        }
+            err = AudioUnitUninitialize(pStreamIn->audioUnit);
+            if (err == noErr)
+                err = AudioComponentInstanceDispose(pStreamIn->audioUnit);
+
+            if (   err != noErr
+                && err != kAudioHardwareBadObjectError)
+            {
+                LogRel(("CoreAudio: Failed to uninit the recording device (%RI32)\n", err));
+            }
+
+            pStreamIn->deviceID      = kAudioDeviceUnknown;
+            pStreamIn->audioUnit     = NULL;
+            pStreamIn->sampleRatio   = 1;
+
+# ifdef VBOX_WITH_AUDIO_CA_CONVERTER
+            coreAudioUninitConvCbCtx(&pStreamIn->convCbCtx);
+# endif
+#else /* VBOX_WITH_AUDIO_CA_QUEUES */
+            if (RTCritSectIsInitialized(&pCAStream->CritSect))
+                RTCritSectDelete(&pCAStream->CritSect);
+#endif
+            if (pStreamIn->pCircBuf)
+            {
+                RTCircBufDestroy(pStreamIn->pCircBuf);
+                pStreamIn->pCircBuf = NULL;
+            }
 
-        ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_UNINIT);
+            ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_UNINIT);
+        }
     }
     else
     {
@@ -2449,6 +3183,7 @@ static int coreAudioDestroyStreamIn(PPDMAUDIOSTREAM pStream)
 static int coreAudioDestroyStreamOut(PPDMAUDIOSTREAM pStream)
 {
     PCOREAUDIOSTREAMOUT pStreamOut = (PCOREAUDIOSTREAMOUT)pStream;
+    PCOREAUDIOSTREAM    pCAStream  = &pStreamOut->Common;
 
     LogFlowFuncEnter();
 
@@ -2459,89 +3194,98 @@ static int coreAudioDestroyStreamOut(PPDMAUDIOSTREAM pStream)
         return VINF_SUCCESS;
     }
 
-    int rc = coreAudioControlStreamOut(&pStreamOut->Stream, PDMAUDIOSTREAMCMD_DISABLE);
+    int rc = coreAudioControlStreamOut(pStreamOut, PDMAUDIOSTREAMCMD_DISABLE);
     if (RT_SUCCESS(rc))
     {
         ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_IN_UNINIT);
 
-        OSStatus err;
+        rc = coreAudioStreamUninit(pCAStream);
+        if (RT_SUCCESS(rc))
+        {
+            OSStatus err;
 
-        /*
-         * Unregister playback device callbacks.
-         */
-        AudioObjectPropertyAddress propAdr = { kAudioDeviceProcessorOverload, kAudioObjectPropertyScopeGlobal,
-                                               kAudioObjectPropertyElementMaster };
+            /*
+             * Unregister playback device callbacks.
+             */
+            AudioObjectPropertyAddress propAdr = { kAudioDeviceProcessorOverload, kAudioObjectPropertyScopeGlobal,
+                                                   kAudioObjectPropertyElementMaster };
 #ifdef DEBUG
-        err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr,
-                                                coreAudioPlaybackAudioDevicePropertyChanged, &pStreamOut->cbCtx);
-        if (   err != noErr
-            && err != kAudioHardwareBadObjectError)
-        {
-            LogRel(("CoreAudio: Failed to remove the playback processor overload listener (%RI32)\n", err));
-        }
+            err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr,
+                                                    coreAudioPlaybackAudioDevicePropertyChanged, &pStreamOut->Common);
+            if (   err != noErr
+                && err != kAudioHardwareBadObjectError)
+            {
+                LogRel(("CoreAudio: Failed to remove the playback processor overload listener (%RI32)\n", err));
+            }
 #endif /* DEBUG */
 
-        propAdr.mSelector = kAudioDevicePropertyNominalSampleRate;
-        err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr,
-                                                coreAudioPlaybackAudioDevicePropertyChanged, &pStreamOut->cbCtx);
-        if (   err != noErr
-            && err != kAudioHardwareBadObjectError)
-        {
-            LogRel(("CoreAudio: Failed to remove the playback sample rate changed listener (%RI32)\n", err));
-        }
-
-        if (pStreamOut->fDefDevChgListReg)
-        {
-            propAdr.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-            propAdr.mScope    = kAudioObjectPropertyScopeGlobal;
-            propAdr.mElement  = kAudioObjectPropertyElementMaster;
-            err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &propAdr,
-                                                    coreAudioDefaultDeviceChanged, &pStreamOut->cbCtx);
+            propAdr.mSelector = kAudioDevicePropertyNominalSampleRate;
+            err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr,
+                                                    coreAudioPlaybackAudioDevicePropertyChanged, &pStreamOut->Common);
             if (   err != noErr
                 && err != kAudioHardwareBadObjectError)
             {
-                LogRel(("CoreAudio: Failed to remove the default playback device changed listener (%RI32)\n", err));
+                LogRel(("CoreAudio: Failed to remove the playback sample rate changed listener (%RI32)\n", err));
             }
 
-            pStreamOut->fDefDevChgListReg = false;
-        }
+            if (pStreamOut->fDefDevChgListReg)
+            {
+                propAdr.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
+                propAdr.mScope    = kAudioObjectPropertyScopeGlobal;
+                propAdr.mElement  = kAudioObjectPropertyElementMaster;
+                err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &propAdr,
+                                                        coreAudioDefaultDeviceChanged, &pStreamOut->Common);
+                if (   err != noErr
+                    && err != kAudioHardwareBadObjectError)
+                {
+                    LogRel(("CoreAudio: Failed to remove the default playback device changed listener (%RI32)\n", err));
+                }
 
-        if (pStreamOut->fDevStateChgListReg)
-        {
-            Assert(pStreamOut->deviceID != kAudioDeviceUnknown);
+                pStreamOut->fDefDevChgListReg = false;
+            }
 
-            AudioObjectPropertyAddress propAdr2 = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
-                                                    kAudioObjectPropertyElementMaster };
-            err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr2,
-                                                    drvHostCoreAudioDeviceStateChanged, &pStreamOut->cbCtx);
-            if (   err != noErr
-                && err != kAudioHardwareBadObjectError)
+            if (pStreamOut->fDevStateChgListReg)
             {
-                LogRel(("CoreAudio: Failed to remove the playback device state changed listener (%RI32)\n", err));
+                Assert(pStreamOut->deviceID != kAudioDeviceUnknown);
+
+                AudioObjectPropertyAddress propAdr2 = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
+                                                        kAudioObjectPropertyElementMaster };
+                err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr2,
+                                                        drvHostCoreAudioDeviceStateChanged, &pStreamOut->Common);
+                if (   err != noErr
+                    && err != kAudioHardwareBadObjectError)
+                {
+                    LogRel(("CoreAudio: Failed to remove the playback device state changed listener (%RI32)\n", err));
+                }
+
+                pStreamOut->fDevStateChgListReg = false;
             }
 
-            pStreamOut->fDevStateChgListReg = false;
-        }
+#ifndef VBOX_WITH_AUDIO_CA_QUEUES
+            err = AudioUnitUninitialize(pStreamOut->audioUnit);
+            if (err == noErr)
+                err = AudioComponentInstanceDispose(pStreamOut->audioUnit);
 
-        err = AudioUnitUninitialize(pStreamOut->audioUnit);
-        if (err == noErr)
-            err = AudioComponentInstanceDispose(pStreamOut->audioUnit);
+            if (   err != noErr
+                && err != kAudioHardwareBadObjectError)
+            {
+                LogRel(("CoreAudio: Failed to uninit the playback device (%RI32)\n", err));
+            }
 
-        if (   err != noErr
-            && err != kAudioHardwareBadObjectError)
-        {
-            LogRel(("CoreAudio: Failed to uninit the playback device (%RI32)\n", err));
-        }
+            pStreamOut->deviceID  = kAudioDeviceUnknown;
+            pStreamOut->audioUnit = NULL;
+#else
+            if (RTCritSectIsInitialized(&pCAStream->CritSect))
+                RTCritSectDelete(&pCAStream->CritSect);
+#endif
+            if (pStreamOut->pCircBuf)
+            {
+                RTCircBufDestroy(pStreamOut->pCircBuf);
+                pStreamOut->pCircBuf = NULL;
+            }
 
-        pStreamOut->deviceID  = kAudioDeviceUnknown;
-        pStreamOut->audioUnit = NULL;
-        if (pStreamOut->pCircBuf)
-        {
-            RTCircBufDestroy(pStreamOut->pCircBuf);
-            pStreamOut->pCircBuf = NULL;
+            ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_UNINIT);
         }
-
-        ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_UNINIT);
     }
     else
         LogRel(("CoreAudio: Failed to stop playback on uninit, rc=%Rrc\n", rc));
@@ -2571,10 +3315,23 @@ static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis,
     pStreamIn->fDefDevChgListReg   = false;
     pStreamIn->fDevStateChgListReg = false;
 
-    /* Set callback context. */
-    pStreamIn->cbCtx.pThis  = pThis;
-    pStreamIn->cbCtx.enmDir = PDMAUDIODIR_IN;
-    pStreamIn->cbCtx.pIn    = pStreamIn;
+    PCOREAUDIOSTREAM pCAStream = &pStreamIn->Common;
+
+    int rc;
+
+    pCAStream->pThis  = pThis;
+    pCAStream->enmDir = PDMAUDIODIR_IN;
+    pCAStream->pIn    = pStreamIn;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = RTCritSectInit(&pCAStream->CritSect);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pCAStream->hThread    = NIL_RTTHREAD;
+    pCAStream->fRun       = false;
+    pCAStream->fIsRunning = false;
+    pCAStream->fShutdown  = false;
+#endif
 
     bool fDeviceByUser = false; /* Do we use a device which was set by the user? */
 
@@ -2590,9 +3347,22 @@ static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis,
             fDeviceByUser = true;
     }
 #endif
-    int rc = coreAudioInitIn(pThis, &pStreamIn->Stream, pCfgReq, pCfgAcq);
+
+    ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_IN_INIT);
+
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = coreAudioStreamInitQueue(pCAStream, true /* fIn */, pCfgReq, pCfgAcq);
+    if (RT_SUCCESS(rc))
+    {
+        pCfgAcq->cSampleBufferSize = _4K; /** @todo FIX THIS !!! */
+    }
+#else
+    rc = coreAudioStreamInitIn(pStreamIn, pCfgReq, pCfgAcq);
+#endif
     if (RT_SUCCESS(rc))
     {
+        ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_INIT);
+
         OSStatus err;
 
         /* When the devices isn't forced by the user, we want default device change notifications. */
@@ -2603,7 +3373,7 @@ static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis,
                 AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal,
                                                        kAudioObjectPropertyElementMaster };
                 err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr,
-                                                     coreAudioDefaultDeviceChanged, &pStreamIn->cbCtx);
+                                                     coreAudioDefaultDeviceChanged, &pStreamIn->Common);
                 if (   err == noErr
                     || err == kAudioHardwareIllegalOperationError)
                 {
@@ -2621,7 +3391,7 @@ static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis,
             AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
                                                    kAudioObjectPropertyElementMaster };
             err = AudioObjectAddPropertyListener(pStreamIn->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged,
-                                                 &pStreamIn->cbCtx);
+                                                 &pStreamIn->Common);
             if (err == noErr)
             {
                 pStreamIn->fDevStateChgListReg = true;
@@ -2654,10 +3424,23 @@ static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis,
     pStreamOut->fDefDevChgListReg   = false;
     pStreamOut->fDevStateChgListReg = false;
 
-    /* Set callback context. */
-    pStreamOut->cbCtx.pThis  = pThis;
-    pStreamOut->cbCtx.enmDir = PDMAUDIODIR_OUT;
-    pStreamOut->cbCtx.pOut   = pStreamOut;
+    PCOREAUDIOSTREAM pCAStream = &pStreamOut->Common;
+
+    int rc;
+
+    pCAStream->pThis  = pThis;
+    pCAStream->enmDir = PDMAUDIODIR_OUT;
+    pCAStream->pOut   = pStreamOut;
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = RTCritSectInit(&pCAStream->CritSect);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pCAStream->hThread    = NIL_RTTHREAD;
+    pCAStream->fRun       = false;
+    pCAStream->fIsRunning = false;
+    pCAStream->fShutdown  = false;
+#endif
 
     bool fDeviceByUser = false; /* Do we use a device which was set by the user? */
 
@@ -2675,9 +3458,20 @@ static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis,
             fDeviceByUser = true;
     }
 #endif
-    int rc = coreAudioInitOut(pThis, pStream, pCfgReq, pCfgAcq);
+
+#ifdef VBOX_WITH_AUDIO_CA_QUEUES
+    rc = coreAudioStreamInitQueue(pCAStream, false /* fIn */, pCfgReq, pCfgAcq);
+    if (RT_SUCCESS(rc))
+    {
+        pCfgAcq->cSampleBufferSize = _4K; /** @todo FIX THIS !!! */
+    }
+#else
+    rc = coreAudioStreamInitOut(pStreamOut, pCfgReq, pCfgAcq);
+#endif
     if (RT_SUCCESS(rc))
     {
+        ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_INIT);
+
         OSStatus err;
 
         /* When the devices isn't forced by the user, we want default device change notifications. */
@@ -2686,7 +3480,7 @@ static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis,
             AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal,
                                                    kAudioObjectPropertyElementMaster };
             err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr,
-                                                 coreAudioDefaultDeviceChanged, &pStreamOut->cbCtx);
+                                                 coreAudioDefaultDeviceChanged, &pStreamOut->Common);
             if (err == noErr)
             {
                 pStreamOut->fDefDevChgListReg = true;
@@ -2702,7 +3496,7 @@ static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis,
             AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
                                                    kAudioObjectPropertyElementMaster };
             err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged,
-                                                 (void *)&pStreamOut->cbCtx);
+                                                 (void *)&pStreamOut->Common);
             if (err == noErr)
             {
                 pStreamOut->fDevStateChgListReg = true;
@@ -2799,9 +3593,9 @@ static DECLCALLBACK(int) drvHostCoreAudioStreamControl(PPDMIHOSTAUDIO pInterface
 
     int rc;
     if (pStream->enmDir == PDMAUDIODIR_IN)
-        rc = coreAudioControlStreamIn(pStream, enmStreamCmd);
+        rc = coreAudioControlStreamIn((PCOREAUDIOSTREAMIN)pStream, enmStreamCmd);
     else
-        rc = coreAudioControlStreamOut(pStream, enmStreamCmd);
+        rc = coreAudioControlStreamOut((PCOREAUDIOSTREAMOUT)pStream, enmStreamCmd);
 
     return rc;
 }
diff --git a/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp b/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
index f6874d5..f4ba434 100644
--- a/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
+++ b/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
@@ -166,17 +166,26 @@ static int debugCreateStreamOut(PPDMIHOSTAUDIO pInterface,
 
     if (RT_SUCCESS(rc))
     {
-        char szFile[RTPATH_MAX];
-        rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), "/tmp/", NULL, PDMAUDIOFILETYPE_WAV);
+        char szTemp[RTPATH_MAX];
+        rc = RTPathTemp(szTemp, sizeof(szTemp));
         if (RT_SUCCESS(rc))
         {
-            LogRel(("DebugAudio: Creating output file '%s'\n", szFile));
-            rc = DrvAudioHlpWAVFileOpen(&pDbgStream->File, szFile,
-                                        RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
-                                        &Props, PDMAUDIOFILEFLAG_NONE);
-            if (RT_FAILURE(rc))
-                LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
+            char szFile[RTPATH_MAX];
+            rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, NULL, PDMAUDIOFILETYPE_WAV);
+            if (RT_SUCCESS(rc))
+            {
+                LogFlowFunc(("%s\n", szFile));
+                rc = DrvAudioHlpWAVFileOpen(&pDbgStream->File, szFile,
+                                            RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
+                                            &Props, PDMAUDIOFILEFLAG_NONE);
+                if (RT_FAILURE(rc))
+                    LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
+            }
+            else
+                LogRel(("DebugAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc));
         }
+        else
+            LogRel(("DebugAudio: Unable to retrieve temp dir: %Rrc\n", rc));
     }
 
     if (RT_SUCCESS(rc))
@@ -326,8 +335,15 @@ static int debugDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStr
     if (RT_SUCCESS(rc))
     {
         /* Delete the file again if nothing but the header was written to it. */
-        if (!cbDataSize)
-            rc = RTFileDelete(pDbgStream->File.szName); /** @todo Make deletion configurable? */
+        bool fDeleteEmptyFiles = true; /** @todo Make deletion configurable? */
+
+        if (   !cbDataSize
+            && fDeleteEmptyFiles)
+        {
+            rc = RTFileDelete(pDbgStream->File.szName);
+        }
+        else
+            LogRel(("DebugAudio: Created output file '%s' (%zu bytes)\n", pDbgStream->File.szName, cbDataSize));
     }
 
     LogFlowFuncLeaveRC(rc);
diff --git a/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp b/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
index ff32521..6b3d2f2 100644
--- a/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
+++ b/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
@@ -852,10 +852,9 @@ static DECLCALLBACK(int) drvHostPulseAudioStreamCapture(PPDMIHOSTAUDIO pInterfac
     if (RT_SUCCESS(rc))
     {
         uint32_t cProcessed = 0;
-      /*  if (cWrittenTotal)
-            rc = AudioMixBufMixToParent(&pStream->MixBuf, cWrittenTotal,
-                                        &cProcessed);*/
-        NOREF(cProcessed);
+        if (cWrittenTotal)
+            rc = AudioMixBufMixToParent(&pStream->MixBuf, cWrittenTotal, &cProcessed);
+
         if (pcbRead)
             *pcbRead = cWrittenTotal;
 
diff --git a/src/VBox/Devices/Bus/DevPciIch9.cpp b/src/VBox/Devices/Bus/DevPciIch9.cpp
index 09fe3fd..bb59981 100644
--- a/src/VBox/Devices/Bus/DevPciIch9.cpp
+++ b/src/VBox/Devices/Bus/DevPciIch9.cpp
@@ -872,7 +872,8 @@ static void ich9pciUpdateMappings(PCIDevice* pDev)
         if (iRegionSize == 0)
             continue;
 
-        bool f64Bit = (pRegion->type & PCI_ADDRESS_SPACE_BAR64) != 0;
+        bool f64Bit =    (pRegion->type & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO)))
+                      == PCI_ADDRESS_SPACE_BAR64;
 
         if (pRegion->type & PCI_ADDRESS_SPACE_IO)
         {
@@ -1627,7 +1628,7 @@ static void ich9pciSetRegionAddress(PICH9PCIGLOBALS pGlobals, uint8_t uBus, uint
 
     /* Read memory type first. */
     uint8_t uResourceType = ich9pciConfigRead(pGlobals, uBus, uDevFn, uReg, 1);
-    bool    f64Bit = (uResourceType & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO)))
+    bool    f64Bit =    (uResourceType & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO)))
                      == PCI_ADDRESS_SPACE_BAR64;
 
     Log(("Set region address: %02x:%02x.%d region %d address=%RX64%s\n",
@@ -1769,7 +1770,8 @@ static void ich9pciBiosInitDevice(PICH9PCIGLOBALS pGlobals, uint8_t uBus, uint8_
                    are cleared. */
                 uint8_t u8ResourceType = ich9pciConfigRead(pGlobals, uBus, uDevFn, u32Address, 1);
 
-                bool f64Bit = (u8ResourceType & PCI_ADDRESS_SPACE_BAR64) != 0;
+                bool f64Bit =    (u8ResourceType & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO)))
+                              == PCI_ADDRESS_SPACE_BAR64;
                 bool fIsPio = ((u8ResourceType & PCI_COMMAND_IOACCESS) == PCI_COMMAND_IOACCESS);
                 uint64_t cbRegSize64 = 0;
 
@@ -2455,7 +2457,8 @@ static void ich9pciBusInfo(PICH9PCIBUS pBus, PCDBGFINFOHLP pHlp, int iIndent, bo
                     const char * pszDesc;
                     char szDescBuf[128];
 
-                    bool f64Bit = !!(pRegion->type & PCI_ADDRESS_SPACE_BAR64);
+                    bool f64Bit =    (pRegion->type & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO)))
+                                  == PCI_ADDRESS_SPACE_BAR64;
                     if (pRegion->type & PCI_ADDRESS_SPACE_IO)
                     {
                         pszDesc = "IO";
diff --git a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd
index 348a7ee..6c31ddd 100644
Binary files a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd and b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd differ
diff --git a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd
index 5d1b0a5..95b0b74 100644
Binary files a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd and b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd differ
diff --git a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.asm b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.asm
index 8dd9a47..74d2093 100644
--- a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.asm
+++ b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.asm
@@ -7293,7 +7293,7 @@ vesa_pm_end:                                 ; 0xc4514 LB 0x1
 
 section _DATA progbits vstart=0x4600 align=1 ; size=0x371e class=DATA group=DGROUP
 _msg_vga_init:                               ; 0xc4600 LB 0x2e
-    db  'Oracle VM VirtualBox Version 5.1.6 VGA BIOS', 00dh, 00ah, 000h
+    db  'Oracle VM VirtualBox Version 5.1.8 VGA BIOS', 00dh, 00ah, 000h
 _vga_modes:                                  ; 0xc462e LB 0x80
     db  000h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 001h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h
     db  002h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 003h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h
@@ -8188,7 +8188,7 @@ _vbebios_vendor_name:                        ; 0xc7c73 LB 0x13
 _vbebios_product_name:                       ; 0xc7c86 LB 0x21
     db  'Oracle VM VirtualBox VBE Adapter', 000h
 _vbebios_product_revision:                   ; 0xc7ca7 LB 0x23
-    db  'Oracle VM VirtualBox Version 5.1.6', 000h
+    db  'Oracle VM VirtualBox Version 5.1.8', 000h
 _vbebios_info_string:                        ; 0xc7cca LB 0x2b
     db  'VirtualBox VBE Display Adapter enabled', 00dh, 00ah, 00dh, 00ah, 000h
 _no_vbebios_info_string:                     ; 0xc7cf5 LB 0x29
@@ -8245,4 +8245,4 @@ section CONST2 progbits vstart=0x7d1e align=1 ; size=0x0 class=DATA group=DGROUP
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
-    db  000h, 07ch
+    db  000h, 078h
diff --git a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.md5sum b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.md5sum
index 7ab9483..17574cb 100644
--- a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.md5sum
+++ b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative286.md5sum
@@ -1 +1 @@
-93b3ef7cb9061e548825521a1fc84ecc *VBoxVgaBios286.rom
+9234056c02f1c75e16b92de939e14af2 *VBoxVgaBios286.rom
diff --git a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.asm b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.asm
index 5be8429..42f8efa 100644
--- a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.asm
+++ b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.asm
@@ -6769,7 +6769,7 @@ vesa_pm_end:                                 ; 0xc4514 LB 0x1
 
 section _DATA progbits vstart=0x4600 align=1 ; size=0x371e class=DATA group=DGROUP
 _msg_vga_init:                               ; 0xc4600 LB 0x2e
-    db  'Oracle VM VirtualBox Version 5.1.6 VGA BIOS', 00dh, 00ah, 000h
+    db  'Oracle VM VirtualBox Version 5.1.8 VGA BIOS', 00dh, 00ah, 000h
 _vga_modes:                                  ; 0xc462e LB 0x80
     db  000h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 001h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h
     db  002h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 003h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h
@@ -7664,7 +7664,7 @@ _vbebios_vendor_name:                        ; 0xc7c73 LB 0x13
 _vbebios_product_name:                       ; 0xc7c86 LB 0x21
     db  'Oracle VM VirtualBox VBE Adapter', 000h
 _vbebios_product_revision:                   ; 0xc7ca7 LB 0x23
-    db  'Oracle VM VirtualBox Version 5.1.6', 000h
+    db  'Oracle VM VirtualBox Version 5.1.8', 000h
 _vbebios_info_string:                        ; 0xc7cca LB 0x2b
     db  'VirtualBox VBE Display Adapter enabled', 00dh, 00ah, 00dh, 00ah, 000h
 _no_vbebios_info_string:                     ; 0xc7cf5 LB 0x29
@@ -7721,4 +7721,4 @@ section CONST2 progbits vstart=0x7d1e align=1 ; size=0x0 class=DATA group=DGROUP
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
-    db  000h, 071h
+    db  000h, 06dh
diff --git a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.md5sum b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.md5sum
index 046cbca..9c41032 100644
--- a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.md5sum
+++ b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative386.md5sum
@@ -1 +1 @@
-e6636bccad2656f5a1922cc3464bbe9e *VBoxVgaBios386.rom
+6500e14d937eefc731fa76c7b1d69bb8 *VBoxVgaBios386.rom
diff --git a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.asm b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.asm
index e8621b3..7ef5e8b 100644
--- a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.asm
+++ b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.asm
@@ -7434,7 +7434,7 @@ vesa_pm_end:                                 ; 0xc4514 LB 0x1
 
 section _DATA progbits vstart=0x4600 align=1 ; size=0x371e class=DATA group=DGROUP
 _msg_vga_init:                               ; 0xc4600 LB 0x2e
-    db  'Oracle VM VirtualBox Version 5.1.6 VGA BIOS', 00dh, 00ah, 000h
+    db  'Oracle VM VirtualBox Version 5.1.8 VGA BIOS', 00dh, 00ah, 000h
 _vga_modes:                                  ; 0xc462e LB 0x80
     db  000h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 001h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h
     db  002h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 003h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h
@@ -8329,7 +8329,7 @@ _vbebios_vendor_name:                        ; 0xc7c73 LB 0x13
 _vbebios_product_name:                       ; 0xc7c86 LB 0x21
     db  'Oracle VM VirtualBox VBE Adapter', 000h
 _vbebios_product_revision:                   ; 0xc7ca7 LB 0x23
-    db  'Oracle VM VirtualBox Version 5.1.6', 000h
+    db  'Oracle VM VirtualBox Version 5.1.8', 000h
 _vbebios_info_string:                        ; 0xc7cca LB 0x2b
     db  'VirtualBox VBE Display Adapter enabled', 00dh, 00ah, 00dh, 00ah, 000h
 _no_vbebios_info_string:                     ; 0xc7cf5 LB 0x29
@@ -8386,4 +8386,4 @@ section CONST2 progbits vstart=0x7d1e align=1 ; size=0x0 class=DATA group=DGROUP
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
-    db  000h, 003h
+    db  000h, 0ffh
diff --git a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.md5sum b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.md5sum
index e77d3de..4414a2f 100644
--- a/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.md5sum
+++ b/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative8086.md5sum
@@ -1 +1 @@
-35576435684c7f5b2ab52a8964fe5959 *VBoxVgaBios8086.rom
+65fac054c07ec9ad1f8222b00ed8d950 *VBoxVgaBios8086.rom
diff --git a/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp b/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
index 0ab4d87..f1945d1 100644
--- a/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
+++ b/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
@@ -2136,7 +2136,10 @@ static int vbvaHandleQueryConf32(PVGASTATE pVGAState, VBVACONF32 *pConf32)
     }
     else if (u32Index == VBOX_VBVA_CONF32_SCREEN_FLAGS)
     {
-        pConf32->u32Value = VBVA_SCREEN_F_ACTIVE | VBVA_SCREEN_F_DISABLED | VBVA_SCREEN_F_BLANK;
+        pConf32->u32Value =  VBVA_SCREEN_F_ACTIVE
+                           | VBVA_SCREEN_F_DISABLED
+                           | VBVA_SCREEN_F_BLANK
+                           | VBVA_SCREEN_F_BLANK2;
     }
     else if (u32Index == VBOX_VBVA_CONF32_MAX_RECORD_SIZE)
     {
diff --git a/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp b/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
index 4ec1a70..06da24a 100644
--- a/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
+++ b/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
@@ -1475,9 +1475,9 @@ static int vboxVDMACrHostCtlProcess(struct VBOXVDMAHOST *pVdma, VBVAEXHOSTCTL *p
 static int vboxVDMASetupScreenInfo(PVGASTATE pVGAState, VBVAINFOSCREEN *pScreen)
 {
     const uint32_t u32ViewIndex = pScreen->u32ViewIndex;
-    const bool fDisabled = RT_BOOL(pScreen->u16Flags & VBVA_SCREEN_F_DISABLED);
+    const uint16_t u16Flags = pScreen->u16Flags;
 
-    if (fDisabled)
+    if (u16Flags & VBVA_SCREEN_F_DISABLED)
     {
         if (   u32ViewIndex < pVGAState->cMonitors
             || u32ViewIndex == UINT32_C(0xFFFFFFFF))
@@ -1490,6 +1490,23 @@ static int vboxVDMASetupScreenInfo(PVGASTATE pVGAState, VBVAINFOSCREEN *pScreen)
     }
     else
     {
+        if (u16Flags & VBVA_SCREEN_F_BLANK2)
+        {
+            if (   u32ViewIndex >= pVGAState->cMonitors
+                && u32ViewIndex != UINT32_C(0xFFFFFFFF))
+            {
+                return VERR_INVALID_PARAMETER;
+            }
+
+            /* Special case for blanking using current video mode.
+             * Only 'u16Flags' and 'u32ViewIndex' field are relevant.
+             */
+            RT_ZERO(*pScreen);
+            pScreen->u32ViewIndex = u32ViewIndex;
+            pScreen->u16Flags = u16Flags;
+            return VINF_SUCCESS;
+        }
+
         if (   u32ViewIndex < pVGAState->cMonitors
             && pScreen->u16BitsPerPixel <= 32
             && pScreen->u32Width <= UINT16_MAX
@@ -1560,7 +1577,9 @@ static int vboxVDMACrGuestCtlResizeEntryProcess(struct VBOXVDMAHOST *pVdma, VBOX
         if (!memcmp(&Screen, &CurScreen, sizeof (CurScreen)))
             continue;
 
-        if (!fDisable || !CurView.u32ViewSize)
+        /* The view does not change if _BLANK2 is set. */
+        if (   (!fDisable || !CurView.u32ViewSize)
+            && !RT_BOOL(Screen.u16Flags & VBVA_SCREEN_F_BLANK2))
         {
             View.u32ViewIndex = Screen.u32ViewIndex;
 
diff --git a/src/VBox/Devices/Makefile.kmk b/src/VBox/Devices/Makefile.kmk
index 629d1e2..7b54167 100644
--- a/src/VBox/Devices/Makefile.kmk
+++ b/src/VBox/Devices/Makefile.kmk
@@ -27,6 +27,9 @@ endif
 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
 include $(PATH_SUB_CURRENT)/Audio/testcase/Makefile.kmk
 include $(PATH_SUB_CURRENT)/Input/testcase/Makefile.kmk
+ifdef VBOX_WITH_TESTCASES
+ include $(PATH_SUB_CURRENT)/Samples/Makefile.kmk
+endif
 if defined(VBOX_WITH_INTEL_PXE) || defined(VBOX_ONLY_EXTPACKS)
  include $(PATH_SUB_CURRENT)/PC/PXE/Makefile.kmk
 else if defined(VBOX_WITH_PXE_ROM)
@@ -534,6 +537,9 @@ if !defined(VBOX_ONLY_EXTPACKS)         # Goes on almost to the end of the file.
   VBoxDD_DEFS += VBOX_WITH_HDA_51_SURROUND
  endif
 
+ # Enable Audio Queues implementation for macOS hosts (Core Audio backend).
+ VBoxDD_DEFS.darwin += VBOX_WITH_AUDIO_CA_QUEUES
+
  VBoxDD_SOURCES         += \
 	Audio/DevIchAc97.cpp \
 	Audio/DevSB16.cpp \
diff --git a/src/VBox/Devices/Network/DrvNAT.cpp b/src/VBox/Devices/Network/DrvNAT.cpp
index af966ca..340a269 100644
--- a/src/VBox/Devices/Network/DrvNAT.cpp
+++ b/src/VBox/Devices/Network/DrvNAT.cpp
@@ -1369,22 +1369,19 @@ static int drvNATConstructRedir(unsigned iInstance, PDRVNAT pThis, PCFGMNODE pCf
 {
     RT_NOREF(pNetwork); /** @todo figure why pNetwork isn't used */
 
+    PCFGMNODE pPFTree = CFGMR3GetChild(pCfg, "PortForwarding");
+    if (pPFTree == NULL)
+        return VINF_SUCCESS;
+
     /*
      * Enumerate redirections.
      */
-    for (PCFGMNODE pNode = CFGMR3GetFirstChild(pCfg); pNode; pNode = CFGMR3GetNextChild(pNode))
+    for (PCFGMNODE pNode = CFGMR3GetFirstChild(pPFTree); pNode; pNode = CFGMR3GetNextChild(pNode))
     {
-#ifdef VBOX_WITH_DNSMAPPING_IN_HOSTRESOLVER
-        char szNodeName[32];
-        CFGMR3GetName(pNode, szNodeName, 32);
-        if (   !RTStrICmp(szNodeName, "HostResolverMappings")
-            || !RTStrICmp(szNodeName, "AttachedDriver"))
-            continue;
-#endif
         /*
          * Validate the port forwarding config.
          */
-        if (!CFGMR3AreValuesValid(pNode, "Protocol\0UDP\0HostPort\0GuestPort\0GuestIP\0BindIP\0"))
+        if (!CFGMR3AreValuesValid(pNode, "Name\0Protocol\0UDP\0HostPort\0GuestPort\0GuestIP\0BindIP\0"))
             return PDMDRV_SET_ERROR(pThis->pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
                                     N_("Unknown configuration in port forwarding"));
 
diff --git a/src/VBox/Devices/Network/slirp/bootp.c b/src/VBox/Devices/Network/slirp/bootp.c
index 11469ee..fe354bb 100644
--- a/src/VBox/Devices/Network/slirp/bootp.c
+++ b/src/VBox/Devices/Network/slirp/bootp.c
@@ -48,7 +48,7 @@ typedef struct
 {
     uint32_t xid;
     bool allocated;
-    uint8_t macaddr[6];
+    uint8_t macaddr[ETH_ALEN];
     struct in_addr addr;
     int number;
 } BOOTPClient;
@@ -62,25 +62,51 @@ static const uint8_t rfc1533_cookie[4] = { RFC1533_COOKIE };
 
 static void bootp_reply(PNATState pData, struct mbuf *m0, int offReply, uint16_t flags);
 
-static uint8_t *dhcp_find_option(uint8_t *vend, uint8_t tag)
+
+static uint8_t *dhcp_find_option(uint8_t *vendor, size_t vlen, uint8_t tag, ssize_t checklen)
 {
-    uint8_t *q = vend;
-    uint8_t len;
-    /** @todo magic validation */
-    q += 4; /*magic*/
-    while(*q != RFC1533_END)
+    uint8_t *q = vendor;
+    size_t len = vlen;
+
+    q += sizeof(rfc1533_cookie);
+    len -= sizeof(rfc1533_cookie);
+
+    while (len > 0)
     {
-        if (*q == RFC1533_PAD)
-        {
-            q++;
+        uint8_t *optptr = q;
+        uint8_t opt;
+        uint8_t optlen;
+
+        opt = *q++;
+        --len;
+
+        if (opt == RFC1533_END)
+            break;
+
+        if (opt == RFC1533_PAD)
             continue;
+
+        if (len == 0)
+            break;              /* no option length byte */
+
+        optlen = *q++;
+        --len;
+
+        if (len < optlen)
+            break;              /* option value truncated */
+
+        if (opt == tag)
+        {
+            if (checklen > 0 && optlen != checklen)
+                break;          /* wrong option size */
+
+            return optptr;
         }
-        if (*q == tag)
-            return q;
-        q++;
-        len = *q;
-        q += 1 + len;
+
+        q += optlen;
+        len -= optlen;
     }
+
     return NULL;
 }
 
@@ -398,7 +424,7 @@ enum DHCP_REQUEST_STATES
     NONE
 };
 
-static int dhcp_decode_request(PNATState pData, struct bootp_t *bp, struct mbuf *m)
+static int dhcp_decode_request(PNATState pData, struct bootp_t *bp, size_t vlen, struct mbuf *m)
 {
     BOOTPClient *bc = NULL;
     struct in_addr daddr;
@@ -409,8 +435,10 @@ static int dhcp_decode_request(PNATState pData, struct bootp_t *bp, struct mbuf
     enum DHCP_REQUEST_STATES dhcp_stat = NONE;
 
     /* need to understand which type of request we get */
-    req_ip = dhcp_find_option(&bp->bp_vend[0], RFC2132_REQ_ADDR);
-    server_ip = dhcp_find_option(&bp->bp_vend[0], RFC2132_SRV_ID);
+    req_ip = dhcp_find_option(bp->bp_vend, vlen,
+                              RFC2132_REQ_ADDR, sizeof(struct in_addr));
+    server_ip = dhcp_find_option(bp->bp_vend, vlen,
+                                 RFC2132_SRV_ID, sizeof(struct in_addr));
 
     bc = find_addr(pData, &daddr, bp->bp_hwaddr);
 
@@ -497,8 +525,7 @@ static int dhcp_decode_request(PNATState pData, struct bootp_t *bp, struct mbuf
                    return -1;
                }
 
-               Assert((bp->bp_hlen == ETH_ALEN));
-               memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen);
+               memcpy(bc->macaddr, bp->bp_hwaddr, ETH_ALEN);
                bc->addr.s_addr = bp->bp_ciaddr.s_addr;
             }
             break;
@@ -543,8 +570,8 @@ static int dhcp_decode_request(PNATState pData, struct bootp_t *bp, struct mbuf
                     return -1;
                 }
             }
-            Assert((bp->bp_hlen == ETH_ALEN));
-            memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen);
+
+            memcpy(bc->macaddr, bp->bp_hwaddr, ETH_ALEN);
             bc->addr.s_addr = ui32;
             break;
 
@@ -583,7 +610,7 @@ static int dhcp_decode_discover(PNATState pData, struct bootp_t *bp, int fDhcpDi
                 Log(("no address left\n"));
                 return -1;
             }
-            memcpy(bc->macaddr, bp->bp_hwaddr, 6);
+            memcpy(bc->macaddr, bp->bp_hwaddr, ETH_ALEN);
         }
 
         bc->xid = bp->bp_xid;
@@ -678,7 +705,7 @@ static int dhcp_decode_release(PNATState pData, struct bootp_t *bp)
  * All others                 MAY           MAY              MUST NOT
  *
  */
-static void dhcp_decode(PNATState pData, struct bootp_t *bp, const uint8_t *buf, int size)
+static void dhcp_decode(PNATState pData, struct bootp_t *bp, size_t vlen)
 {
     const uint8_t *pu8RawDhcpObject;
     int rc;
@@ -687,18 +714,15 @@ static void dhcp_decode(PNATState pData, struct bootp_t *bp, const uint8_t *buf,
     uint8_t *parameter_list = NULL;
     struct mbuf *m = NULL;
 
-    pu8RawDhcpObject = buf;
-    if (size < 5)
+    if (memcmp(bp->bp_vend, rfc1533_cookie, sizeof(rfc1533_cookie)) != 0)
         return;
 
-    if (memcmp(pu8RawDhcpObject, rfc1533_cookie, 4) != 0)
+    pu8RawDhcpObject = dhcp_find_option(bp->bp_vend, vlen, RFC2132_MSG_TYPE, 1);
+    if (pu8RawDhcpObject == NULL)
         return;
-
-    /* note: pu8RawDhcpObject doesn't point to parameter buf */
-    pu8RawDhcpObject = dhcp_find_option(bp->bp_vend, RFC2132_MSG_TYPE);
-    Assert(pu8RawDhcpObject);
-    if (!pu8RawDhcpObject)
+    if (pu8RawDhcpObject[1] != 1) /* option length */
         return;
+
     /**
      * We're going update dns list at least once per DHCP transaction (!not on every operation
      * within transaction), assuming that transaction can't be longer than 1 min.
@@ -719,11 +743,12 @@ static void dhcp_decode(PNATState pData, struct bootp_t *bp, const uint8_t *buf,
             || curtime - pData->dnsLastUpdate > 60 * 1000 /* one minute */
             || pData->fUseHostResolver))
     {
-        uint8_t i = 2; /* i = 0 - tag, i == 1 - length */
-        parameter_list = dhcp_find_option(&bp->bp_vend[0], RFC2132_PARAM_LIST);
-        for (;parameter_list && i < parameter_list[1]; ++i)
+        uint8_t i;
+
+        parameter_list = dhcp_find_option(bp->bp_vend, vlen, RFC2132_PARAM_LIST, -1);
+        for (i = 0; parameter_list && i < parameter_list[1]; ++i)
         {
-            if (parameter_list[i] == RFC1533_DNS)
+            if (parameter_list[2 + i] == RFC1533_DNS)
             {
                 /* XXX: How differs it from host Suspend/Resume? */
                 slirpReleaseDnsSettings(pData);
@@ -753,7 +778,7 @@ static void dhcp_decode(PNATState pData, struct bootp_t *bp, const uint8_t *buf,
             break;
 
         case DHCPREQUEST:
-            rc = dhcp_decode_request(pData, bp, m);
+            rc = dhcp_decode_request(pData, bp, vlen, m);
             if (rc > 0)
                 goto reply;
             break;
@@ -764,15 +789,14 @@ static void dhcp_decode(PNATState pData, struct bootp_t *bp, const uint8_t *buf,
             break;
 
         case DHCPDECLINE:
-            /* note: pu8RawDhcpObject doesn't point to DHCP header, now it's expected it points
-             * to Dhcp Option RFC2132_REQ_ADDR
-             */
-            pu8RawDhcpObject = dhcp_find_option(&bp->bp_vend[0], RFC2132_REQ_ADDR);
-            if (!pu8RawDhcpObject)
+            pu8RawDhcpObject = dhcp_find_option(bp->bp_vend, vlen,
+                                                RFC2132_REQ_ADDR, sizeof(struct in_addr));
+            if (pu8RawDhcpObject == NULL)
             {
                 Log(("NAT: RFC2132_REQ_ADDR not found\n"));
                 break;
             }
+
             req_ip.s_addr = *(uint32_t *)(pu8RawDhcpObject + 2);
             rc = bootp_cache_lookup_ether_by_ip(pData, req_ip.s_addr, NULL);
             if (RT_FAILURE(rc))
@@ -842,9 +866,41 @@ static void bootp_reply(PNATState pData, struct mbuf *m, int offReply, uint16_t
 void bootp_input(PNATState pData, struct mbuf *m)
 {
     struct bootp_t *bp = mtod(m, struct bootp_t *);
+    u_int mlen = m_length(m, NULL);
+    size_t vlen;
+
+    if (mlen < RT_OFFSETOF(struct bootp_t, bp_vend) + sizeof(rfc1533_cookie))
+    {
+        LogRelMax(50, ("NAT: ignoring invalid BOOTP request (mlen %u too short)\n", mlen));
+        return;
+    }
+
+    if (bp->bp_op != BOOTP_REQUEST)
+    {
+        LogRelMax(50, ("NAT: ignoring invalid BOOTP request (wrong opcode %u)\n", bp->bp_op));
+        return;
+    }
+
+    if (bp->bp_htype != RTNET_ARP_ETHER)
+    {
+        LogRelMax(50, ("NAT: ignoring invalid BOOTP request (wrong HW type %u)\n", bp->bp_htype));
+        return;
+    }
+
+    if (bp->bp_hlen != ETH_ALEN)
+    {
+        LogRelMax(50, ("NAT: ignoring invalid BOOTP request (wrong HW address length %u)\n", bp->bp_hlen));
+        return;
+    }
+
+    if (bp->bp_hops != 0)
+    {
+        LogRelMax(50, ("NAT: ignoring invalid BOOTP request (wrong hop count %u)\n", bp->bp_hops));
+        return;
+    }
 
-    if (bp->bp_op == BOOTP_REQUEST)
-        dhcp_decode(pData, bp, bp->bp_vend, DHCP_OPT_LEN);
+    vlen = mlen - RT_OFFSETOF(struct bootp_t, bp_vend);
+    dhcp_decode(pData, bp, vlen);
 }
 
 int bootp_cache_lookup_ip_by_ether(PNATState pData,const uint8_t* ether, uint32_t *pip)
diff --git a/src/VBox/Devices/Network/slirp/resolv_conf_parser.c b/src/VBox/Devices/Network/slirp/resolv_conf_parser.c
index 70d720e..9d20051 100644
--- a/src/VBox/Devices/Network/slirp/resolv_conf_parser.c
+++ b/src/VBox/Devices/Network/slirp/resolv_conf_parser.c
@@ -370,6 +370,11 @@ int rcp_parse(struct rcp_state *state, const char *filename)
             while ((tok = getToken(NULL, &s)) && !NO_VALUE(tok))
             {
                 i = state->rcps_num_searchlist;
+                if (RT_UNLIKELY(i >= RCPS_MAX_SEARCHLIST))
+                {
+                    LogRel(("NAT: resolv.conf: too many search domains, ignoring %s\n", tok));
+                    continue;
+                }
 
                 Log2(("NAT: resolv.conf: saving search @%td,+%zu\n",
                       pszSearchBuf - state->rcps_searchlist_buffer, cbSearchBuf));
diff --git a/src/VBox/Devices/Network/slirp/socket.c b/src/VBox/Devices/Network/slirp/socket.c
index 7d504ce..813f4c1 100644
--- a/src/VBox/Devices/Network/slirp/socket.c
+++ b/src/VBox/Devices/Network/slirp/socket.c
@@ -362,14 +362,17 @@ soread(PNATState pData, struct socket *so)
         else
         {
             int fUninitializedTemplate = 0;
+            int shuterr;
+
             fUninitializedTemplate = RT_BOOL((   sototcpcb(so)
                                               && (  sototcpcb(so)->t_template.ti_src.s_addr == INADDR_ANY
                                                  || sototcpcb(so)->t_template.ti_dst.s_addr == INADDR_ANY)));
             /* nn == 0 means peer has performed an orderly shutdown */
             Log2(("%s: disconnected, nn = %d, errno = %d (%s)\n",
                   RT_GCC_EXTENSION __PRETTY_FUNCTION__, nn, sockerr, strerror(sockerr)));
-            sofcantrcvmore(so);
-            if (!fUninitializedTemplate)
+
+            shuterr = sofcantrcvmore(so);
+            if (!sockerr && !shuterr && !fUninitializedTemplate)
                 tcp_sockclosed(pData, sototcpcb(so));
             else
                 tcp_drop(pData, sototcpcb(so), sockerr);
@@ -1100,21 +1103,42 @@ soisfconnected(struct socket *so)
     LogFlowFunc(("LEAVE: so:%R[natsock]\n", so));
 }
 
-void
+int
 sofcantrcvmore(struct  socket *so)
 {
+    int err = 0;
+
     LogFlowFunc(("ENTER: so:%R[natsock]\n", so));
     if ((so->so_state & SS_NOFDREF) == 0)
     {
-        shutdown(so->s, 0);
+        /*
+         * If remote closes first and then sends an RST, the recv() in
+         * soread() will keep reporting EOF without any error
+         * indication, so we must also check if shutdown() succeeds
+         * here.
+         */
+        int status = shutdown(so->s, 0);
+        if (status < 0)
+            err = errno;
     }
     so->so_state &= ~(SS_ISFCONNECTING);
     if (so->so_state & SS_FCANTSENDMORE)
+    {
+        /*
+         * If we have closed first, and remote closes, shutdown will
+         * return ENOTCONN, but this is expected.  Don't tell the
+         * caller there was an error.
+         */
+        if (err == ENOTCONN)
+            err = 0;
         so->so_state = SS_NOFDREF; /* Don't select it */
                                    /* XXX close() here as well? */
+    }
     else
         so->so_state |= SS_FCANTRCVMORE;
-    LogFlowFuncLeave();
+
+    LogFlowFunc(("LEAVE: %d\n", err));
+    return err;
 }
 
 void
diff --git a/src/VBox/Devices/Network/slirp/socket.h b/src/VBox/Devices/Network/slirp/socket.h
index 1f90900..5324532 100644
--- a/src/VBox/Devices/Network/slirp/socket.h
+++ b/src/VBox/Devices/Network/slirp/socket.h
@@ -181,7 +181,7 @@ void sorwakeup (struct socket *);
 void sowwakeup (struct socket *);
 void soisfconnecting (register struct socket *);
 void soisfconnected (register struct socket *);
-void sofcantrcvmore (struct  socket *);
+int sofcantrcvmore (struct  socket *);
 void sofcantsendmore (struct socket *);
 void soisfdisconnected (struct socket *);
 void sofwdrain (struct socket *);
diff --git a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.asm b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.asm
index 4068ee9..cc9696f 100644
--- a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.asm
+++ b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.asm
@@ -1115,7 +1115,7 @@ section CONST progbits vstart=0xb0 align=1 ; size=0xcde class=DATA group=DGROUP
 
 section CONST2 progbits vstart=0xd8e align=1 ; size=0x3fa class=DATA group=DGROUP
 _bios_cvs_version_string:                    ; 0xf0d8e LB 0x12
-    db  'VirtualBox 5.1.6', 000h, 000h
+    db  'VirtualBox 5.1.8', 000h, 000h
 _bios_prefix_string:                         ; 0xf0da0 LB 0x8
     db  'BIOS: ', 000h, 000h
 _isotag:                                     ; 0xf0da8 LB 0x6
@@ -17798,4 +17798,4 @@ biosorg_check_before_or_at_0FFEEh:           ; 0xfff80 LB 0x70
     db  'XM'
 cpu_reset:                                   ; 0xffff0 LB 0x10
     jmp far 0f000h:0e05bh                     ; ea 5b e0 00 f0
-    db  030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fch, 085h
+    db  030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fch, 083h
diff --git a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.md5sum b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.md5sum
index 3eccb07..a11e98c 100644
--- a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.md5sum
+++ b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative286.md5sum
@@ -1 +1 @@
-8d283db6e2cf25fe325e422a7059af2f *VBoxPcBios286.rom
+746d52a3293874115332c075b679f9cf *VBoxPcBios286.rom
diff --git a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm
index a666199..2a45899 100644
--- a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm
+++ b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm
@@ -1078,7 +1078,7 @@ section CONST progbits vstart=0xb0 align=1 ; size=0xcde class=DATA group=DGROUP
 
 section CONST2 progbits vstart=0xd8e align=1 ; size=0x3fa class=DATA group=DGROUP
 _bios_cvs_version_string:                    ; 0xf0d8e LB 0x12
-    db  'VirtualBox 5.1.6', 000h, 000h
+    db  'VirtualBox 5.1.8', 000h, 000h
 _bios_prefix_string:                         ; 0xf0da0 LB 0x8
     db  'BIOS: ', 000h, 000h
 _isotag:                                     ; 0xf0da8 LB 0x6
@@ -17197,4 +17197,4 @@ biosorg_check_before_or_at_0FFEEh:           ; 0xfff80 LB 0x70
     db  'XM'
 cpu_reset:                                   ; 0xffff0 LB 0x10
     jmp far 0f000h:0e05bh                     ; ea 5b e0 00 f0
-    db  030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fch, 016h
+    db  030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fch, 014h
diff --git a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.md5sum b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.md5sum
index 067ed80..e375c28 100644
--- a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.md5sum
+++ b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.md5sum
@@ -1 +1 @@
-94e364df8bb6ff7b914414b7e90b798c *VBoxPcBios386.rom
+f74c607b2fee27c05848ec35b9ee4e54 *VBoxPcBios386.rom
diff --git a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.asm b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.asm
index 732f2be..de585f2 100644
--- a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.asm
+++ b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.asm
@@ -1115,7 +1115,7 @@ section CONST progbits vstart=0xb0 align=1 ; size=0xcde class=DATA group=DGROUP
 
 section CONST2 progbits vstart=0xd8e align=1 ; size=0x3fa class=DATA group=DGROUP
 _bios_cvs_version_string:                    ; 0xf0d8e LB 0x12
-    db  'VirtualBox 5.1.6', 000h, 000h
+    db  'VirtualBox 5.1.8', 000h, 000h
 _bios_prefix_string:                         ; 0xf0da0 LB 0x8
     db  'BIOS: ', 000h, 000h
 _isotag:                                     ; 0xf0da8 LB 0x6
@@ -18273,4 +18273,4 @@ biosorg_check_before_or_at_0FFEEh:           ; 0xfff80 LB 0x70
     db  'XM'
 cpu_reset:                                   ; 0xffff0 LB 0x10
     jmp far 0f000h:0e05bh                     ; ea 5b e0 00 f0
-    db  030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fbh, 033h
+    db  030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fbh, 031h
diff --git a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.md5sum b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.md5sum
index 51b1ec1..49287c3 100644
--- a/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.md5sum
+++ b/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative8086.md5sum
@@ -1 +1 @@
-50a063ed79ce0ccf7dd9140a582a0cbb *VBoxPcBios8086.rom
+310200850223ce2fb16f39636fb9125f *VBoxPcBios8086.rom
diff --git a/src/VBox/Devices/Samples/DevPlayground.cpp b/src/VBox/Devices/Samples/DevPlayground.cpp
new file mode 100644
index 0000000..d60d178
--- /dev/null
+++ b/src/VBox/Devices/Samples/DevPlayground.cpp
@@ -0,0 +1,230 @@
+/* $Id: DevPlayground.cpp $ */
+/** @file
+ * DevPlayground - Device for making PDM/PCI/... experiments.
+ *
+ * This device uses big PCI BAR64 resources, which needs the ICH9 chipset.
+ * The device works without any PCI config (because the default setup with the
+ * ICH9 chipset doesn't have anything at bus=0, device=0, function=0.
+ *
+ * To enable this device for a particular VM:
+ * VBoxManage setextradata vmname VBoxInternal/PDM/Devices/playground/Path .../obj/VBoxSampleDevice/VBoxSampleDevice
+ * VBoxManage setextradata vmname VBoxInternal/Devices/playground/0/Config/Whatever1 0
+ */
+
+/*
+ * Copyright (C) 2009-2016 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP LOG_GROUP_MISC
+#include <VBox/vmm/pdmdev.h>
+#include <VBox/version.h>
+#include <VBox/err.h>
+#include <VBox/log.h>
+
+#include <iprt/assert.h>
+
+
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
+/**
+ * Device Instance Data.
+ */
+typedef struct VBOXPLAYGROUNDDEVICE
+{
+    /** The PCI device. */
+    PCIDEVICE           PciDev;
+} VBOXPLAYGROUNDDEVICE;
+typedef VBOXPLAYGROUNDDEVICE *PVBOXPLAYGROUNDDEVICE;
+
+
+/*********************************************************************************************************************************
+*   Device Functions                                                                                                             *
+*********************************************************************************************************************************/
+/**
+ * @interface_method_impl{PDMDEVREG,pfnDestruct}
+ */
+static DECLCALLBACK(int) devPlaygroundDestruct(PPDMDEVINS pDevIns)
+{
+    /*
+     * Check the versions here as well since the destructor is *always* called.
+     */
+    AssertMsgReturn(pDevIns->u32Version            == PDM_DEVINS_VERSION, ("%#x, expected %#x\n", pDevIns->u32Version,            PDM_DEVINS_VERSION), VERR_VERSION_MISMATCH);
+    AssertMsgReturn(pDevIns->pHlpR3->u32Version == PDM_DEVHLPR3_VERSION, ("%#x, expected %#x\n", pDevIns->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), VERR_VERSION_MISMATCH);
+
+    return VINF_SUCCESS;
+}
+
+
+PDMBOTHCBDECL(int) devPlaygroundMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
+{
+    NOREF(pDevIns);
+    NOREF(pvUser);
+    NOREF(GCPhysAddr);
+    NOREF(pv);
+    NOREF(cb);
+    return VINF_SUCCESS;
+}
+
+
+PDMBOTHCBDECL(int) devPlaygroundMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
+{
+    NOREF(pDevIns);
+    NOREF(pvUser);
+    NOREF(GCPhysAddr);
+    NOREF(pv);
+    NOREF(cb);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @callback_method_impl{FNPCIIOREGIONMAP}
+ */
+static DECLCALLBACK(int) devPlaygroundMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
+{
+    NOREF(enmType);
+    int rc;
+
+    switch (iRegion)
+    {
+        case 0:
+            rc = PDMDevHlpMMIORegister(pPciDev->pDevIns, GCPhysAddress, cb, NULL,
+                                       IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
+                                       devPlaygroundMMIOWrite, devPlaygroundMMIORead, "PG-BAR0");
+            break;
+        case 2:
+            rc = PDMDevHlpMMIORegister(pPciDev->pDevIns, GCPhysAddress, cb, NULL,
+                                       IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
+                                       devPlaygroundMMIOWrite, devPlaygroundMMIORead, "PG-BAR2");
+            break;
+        default:
+            /* We should never get here */
+            AssertMsgFailed(("Invalid PCI region param in map callback"));
+            rc = VERR_INTERNAL_ERROR;
+    }
+    return rc;
+
+}
+
+
+/**
+ * @interface_method_impl{PDMDEVREG,pfnConstruct}
+ */
+static DECLCALLBACK(int) devPlaygroundConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
+{
+    NOREF(iInstance);
+
+    /*
+     * Check that the device instance and device helper structures are compatible.
+     */
+    AssertLogRelMsgReturn(pDevIns->u32Version            == PDM_DEVINS_VERSION, ("%#x, expected %#x\n", pDevIns->u32Version,            PDM_DEVINS_VERSION), VERR_VERSION_MISMATCH);
+    AssertLogRelMsgReturn(pDevIns->pHlpR3->u32Version == PDM_DEVHLPR3_VERSION, ("%#x, expected %#x\n", pDevIns->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), VERR_VERSION_MISMATCH);
+
+    /*
+     * Initialize the instance data so that the destructor won't mess up.
+     */
+    PVBOXPLAYGROUNDDEVICE pThis = PDMINS_2_DATA(pDevIns, PVBOXPLAYGROUNDDEVICE);
+    PCIDevSetVendorId(&pThis->PciDev, 0x80ee);
+    PCIDevSetDeviceId(&pThis->PciDev, 0xde4e);
+    PCIDevSetClassBase(&pThis->PciDev, 0x07);   /* communications device */
+    PCIDevSetClassSub(&pThis->PciDev, 0x80);    /* other communications device */
+
+    /*
+     * Validate and read the configuration.
+     */
+    if (!CFGMR3AreValuesValid(pCfg,
+                              "Whatever1\0"
+                              "Whatever2\0"))
+        return VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES;
+
+    /*
+     * PCI device setup.
+     */
+    int rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev);
+    if (RT_FAILURE(rc))
+        return rc;
+    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 8*_1G64,
+                                      (PCIADDRESSSPACE)(PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_BAR64),
+                                      devPlaygroundMap);
+    if (RT_FAILURE(rc))
+        return rc;
+    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, 8*_1G64,
+                                      (PCIADDRESSSPACE)(PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_BAR64),
+                                      devPlaygroundMap);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    return VINF_SUCCESS;
+}
+
+RT_C_DECLS_BEGIN
+extern const PDMDEVREG g_DevicePlayground;
+RT_C_DECLS_END
+
+/**
+ * The device registration structure.
+ */
+const PDMDEVREG g_DevicePlayground =
+{
+    /* u32Version */
+    PDM_DEVREG_VERSION,
+    /* szName */
+    "playground",
+    /* szRCMod */
+    "",
+    /* szR0Mod */
+    "",
+    /* pszDescription */
+    "VBox Playground Device.",
+    /* fFlags */
+    PDM_DEVREG_FLAGS_DEFAULT_BITS,
+    /* fClass */
+    PDM_DEVREG_CLASS_MISC,
+    /* cMaxInstances */
+    1,
+    /* cbInstance */
+    sizeof(VBOXPLAYGROUNDDEVICE),
+    /* pfnConstruct */
+    devPlaygroundConstruct,
+    /* pfnDestruct */
+    devPlaygroundDestruct,
+    /* pfnRelocate */
+    NULL,
+    /* pfnMemSetup */
+    NULL,
+    /* pfnPowerOn */
+    NULL,
+    /* pfnReset */
+    NULL,
+    /* pfnSuspend */
+    NULL,
+    /* pfnResume */
+    NULL,
+    /* pfnAttach */
+    NULL,
+    /* pfnDetach */
+    NULL,
+    /* pfnQueryInterface */
+    NULL,
+    /* pfnInitComplete */
+    NULL,
+    /* pfnPowerOff */
+    NULL,
+    /* pfnSoftReset */
+    NULL,
+    /* u32VersionEnd */
+    PDM_DEVREG_VERSION
+};
diff --git a/src/VBox/Devices/Samples/DrvStorageFilter.cpp b/src/VBox/Devices/Samples/DrvStorageFilter.cpp
index b087426..3e0b59d 100644
--- a/src/VBox/Devices/Samples/DrvStorageFilter.cpp
+++ b/src/VBox/Devices/Samples/DrvStorageFilter.cpp
@@ -20,8 +20,9 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
 #define LOG_GROUP LOG_GROUP_MISC
-#include <VBox/vmm/pdmifs.h>
 #include <VBox/vmm/pdmdrv.h>
+#include <VBox/vmm/pdmstorageifs.h>
+#include <VBox/version.h>
 #include <VBox/log.h>
 
 #include <iprt/uuid.h>
@@ -413,8 +414,11 @@ extern "C" DECLEXPORT(int) VBoxDriversRegister(PPDMDRVREGCB pCallbacks, uint32_t
     LogFlow(("VBoxSampleDriver::VBoxDriversRegister: u32Version=%#x pCallbacks->u32Version=%#x\n",
              u32Version, pCallbacks->u32Version));
 
+    AssertLogRelMsgReturn(u32Version >= VBOX_VERSION,
+                          ("VirtualBox version %#x, expected %#x or higher\n", u32Version, VBOX_VERSION),
+                          VERR_VERSION_MISMATCH);
     AssertLogRelMsgReturn(pCallbacks->u32Version == PDM_DRVREG_CB_VERSION,
-                          ("%#x, expected %#x\n", pCallbacks->u32Version, PDM_DRVREG_CB_VERSION),
+                          ("callback version %#x, expected %#x\n", pCallbacks->u32Version, PDM_DRVREG_CB_VERSION),
                           VERR_VERSION_MISMATCH);
 
     return pCallbacks->pfnRegister(pCallbacks, &g_DrvStorageFilter);
diff --git a/src/VBox/Devices/Samples/Makefile.kmk b/src/VBox/Devices/Samples/Makefile.kmk
index dd72976..88805b1 100644
--- a/src/VBox/Devices/Samples/Makefile.kmk
+++ b/src/VBox/Devices/Samples/Makefile.kmk
@@ -24,9 +24,9 @@ include $(KBUILD_PATH)/subheader.kmk
 #
 DLLS += VBoxSampleDevice
 VBoxSampleDevice_TEMPLATE = VBOXR3
-VBoxSampleDevice_INSTTYPE = none
 VBoxSampleDevice_SOURCES  = \
-	VBoxSampleDevice.cpp
+	VBoxSampleDevice.cpp \
+	DevPlayground.cpp
 VBoxSampleDevice_LIBS     = \
 	$(LIB_RUNTIME) \
 	$(LIB_VMM) \
@@ -37,7 +37,6 @@ VBoxSampleDevice_LIBS     = \
 #
 DLLS += VBoxSampleDriver
 VBoxSampleDriver_TEMPLATE = VBOXR3
-VBoxSampleDriver_INSTTYPE = none
 VBoxSampleDriver_SOURCES  = \
 	DrvStorageFilter.cpp
 VBoxSampleDriver_LIBS     = \
diff --git a/src/VBox/Devices/Samples/VBoxSampleDevice.cpp b/src/VBox/Devices/Samples/VBoxSampleDevice.cpp
index 059d1c2..75e7460 100644
--- a/src/VBox/Devices/Samples/VBoxSampleDevice.cpp
+++ b/src/VBox/Devices/Samples/VBoxSampleDevice.cpp
@@ -42,11 +42,6 @@ typedef VBOXSAMPLEDEVICE *PVBOXSAMPLEDEVICE;
 
 
 
-
-    FNPDMDEVCONSTRUCT  pfnConstruct;
-    /** Destruct instance - optional. */
-    FNPDMDEVDESTRUCT   pfnDestruct;
-
 static DECLCALLBACK(int) devSampleDestruct(PPDMDEVINS pDevIns)
 {
     /*
@@ -68,7 +63,7 @@ static DECLCALLBACK(int) devSampleConstruct(PPDMDEVINS pDevIns, int iInstance, P
     AssertLogRelMsgReturn(pDevIns->pHlpR3->u32Version == PDM_DEVHLPR3_VERSION, ("%#x, expected %#x\n", pDevIns->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), VERR_VERSION_MISMATCH);
 
     /*
-     * Initialize the instance data so that the destructure won't mess up.
+     * Initialize the instance data so that the destructor won't mess up.
      */
     PVBOXSAMPLEDEVICE pThis = PDMINS_2_DATA(pDevIns, PVBOXSAMPLEDEVICE);
     pThis->Whatever = 0;
@@ -81,6 +76,11 @@ static DECLCALLBACK(int) devSampleConstruct(PPDMDEVINS pDevIns, int iInstance, P
                               "Whatever2\0"))
         return VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES;
 
+    /*
+     * Use the instance number if necessary (not for this device, which in
+     * g_DeviceSample below declares a maximum instance count of 1).
+     */
+    NOREF(iInstance);
 
     return VINF_SUCCESS;
 }
@@ -143,7 +143,7 @@ static const PDMDEVREG g_DeviceSample =
 
 
 /**
- * Register builtin devices.
+ * Register devices provided by the plugin.
  *
  * @returns VBox status code.
  * @param   pCallbacks      Pointer to the callback table.
@@ -153,10 +153,18 @@ extern "C" DECLEXPORT(int) VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t
 {
     LogFlow(("VBoxSampleDevice::VBoxDevicesRegister: u32Version=%#x pCallbacks->u32Version=%#x\n", u32Version, pCallbacks->u32Version));
 
+    AssertLogRelMsgReturn(u32Version >= VBOX_VERSION,
+                          ("VirtualBox version %#x, expected %#x or higher\n", u32Version, VBOX_VERSION),
+                          VERR_VERSION_MISMATCH);
     AssertLogRelMsgReturn(pCallbacks->u32Version == PDM_DEVREG_CB_VERSION,
-                          ("%#x, expected %#x\n", pCallbacks->u32Version, PDM_DEVREG_CB_VERSION),
+                          ("callback version %#x, expected %#x\n", pCallbacks->u32Version, PDM_DEVREG_CB_VERSION),
                           VERR_VERSION_MISMATCH);
 
-    return pCallbacks->pfnRegister(pCallbacks, &g_DeviceSample);
+    /* Two devices in this module. */
+    extern const PDMDEVREG g_DevicePlayground;
+    int rc = pCallbacks->pfnRegister(pCallbacks, &g_DeviceSample);
+    if (RT_SUCCESS(rc))
+        rc = pCallbacks->pfnRegister(pCallbacks, &g_DevicePlayground);
+    return rc;
 }
 
diff --git a/src/VBox/Devices/VirtIO/Virtio.cpp b/src/VBox/Devices/VirtIO/Virtio.cpp
index 7c2e43d..63741f6 100644
--- a/src/VBox/Devices/VirtIO/Virtio.cpp
+++ b/src/VBox/Devices/VirtIO/Virtio.cpp
@@ -143,6 +143,28 @@ bool vqueueGet(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem, bool fRemov
     {
         VQUEUESEG *pSeg;
 
+        /*
+         * Malicious guests may try to trick us into writing beyond aSegsIn or
+         * aSegsOut boundaries by linking several descriptors into a loop. We
+         * cannot possibly get a sequence of linked descriptors exceeding the
+         * total number of descriptors in the ring (see @bugref{8620}).
+         */
+        if (pElem->nIn + pElem->nOut >= VRING_MAX_SIZE)
+        {
+            static volatile uint32_t s_cMessages  = 0;
+            static volatile uint32_t s_cThreshold = 1;
+            if (ASMAtomicIncU32(&s_cMessages) == ASMAtomicReadU32(&s_cThreshold))
+            {
+                LogRel(("%s: too many linked descriptors; check if the guest arranges descriptors in a loop.\n",
+                        INSTANCE(pState)));
+                if (ASMAtomicReadU32(&s_cMessages) != 1)
+                    LogRel(("%s: (the above error has occured %u times so far)\n",
+                            INSTANCE(pState), ASMAtomicReadU32(&s_cMessages)));
+                ASMAtomicWriteU32(&s_cThreshold, ASMAtomicReadU32(&s_cThreshold) * 10);
+            }
+            break;
+        }
+        
         vringReadDesc(pState, &pQueue->VRing, idx, &desc);
         if (desc.u16Flags & VRINGDESC_F_WRITE)
         {
diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp b/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
index 4ded051..3777ede 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
@@ -1801,6 +1801,7 @@ HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
                 const char *pszMonitorStatus = "unknown status";
                 switch (monitorStatus)
                 {
+                    case GuestMonitorStatus_Blank:    pszMonitorStatus = "blank"; break;
                     case GuestMonitorStatus_Enabled:  pszMonitorStatus = "enabled"; break;
                     case GuestMonitorStatus_Disabled: pszMonitorStatus = "disabled"; break;
                     default: break;
diff --git a/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp b/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
index 4dfc659..3e4517c 100644
--- a/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
@@ -4456,6 +4456,11 @@ void VBoxGlobal::sltHandleVBoxSVCAvailabilityChange(bool fAvailable)
             /* If that is Selector UI: */
             if (!isVMConsoleProcess())
             {
+                /* Recreate Main event listeners: */
+                UIVirtualBoxEventHandler::destroy();
+                UIExtraDataManager::destroy();
+                UIExtraDataManager::instance();
+                UIVirtualBoxEventHandler::instance();
                 /* Recreate/show selector-window: */
                 UISelectorWindow::destroy();
                 UISelectorWindow::create();
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp b/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
index 24c4b41..83aef6c 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
@@ -373,7 +373,7 @@ bool UIKeyboardHandler::finaliseCaptureKeyboard()
          if (!isItListenedView(QApplication::widgetAt(QCursor::pos())))
              xcb_grab_button_checked(QX11Info::connection(), 0, QX11Info::appRootWindow(),
                                      XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
-                                     XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, XCB_MOD_MASK_ANY);
+                                     XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY);
         /* And grab the keyboard, using XCB directly, as Qt does not report failure. */
         xcb_grab_keyboard_cookie_t xcbGrabCookie = xcb_grab_keyboard(QX11Info::connection(), false, m_views[m_iKeyboardCaptureViewIndex]->winId(),
                                                                      XCB_TIME_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
@@ -382,7 +382,7 @@ bool UIKeyboardHandler::finaliseCaptureKeyboard()
         {
             /* Release the mouse button grab.
              * We do not check for failure as we do not currently implement a back-up plan. */
-            xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_1,
+            xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_ANY,
                                       QX11Info::appRootWindow(), XCB_MOD_MASK_ANY);
             /* Try again later: */
             free(pGrabReply);
@@ -484,7 +484,7 @@ void UIKeyboardHandler::releaseKeyboard()
         xcb_ungrab_keyboard(QX11Info::connection(), XCB_TIME_CURRENT_TIME);
         /* Release the mouse button grab.
          * We do not check for failure as we do not currently implement a back-up plan. */
-        xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_1,
+        xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_ANY,
                                   QX11Info::appRootWindow(), XCB_MOD_MASK_ANY);
 
 # endif /* QT_VERSION >= 0x050000 */
@@ -1214,6 +1214,16 @@ bool UIKeyboardHandler::nativeEventFilter(void *pMessage, ulong uScreenId)
         case WM_SYSKEYDOWN:
         case WM_SYSKEYUP:
         {
+            // WORKAROUND:
+            // Can't do COM inter-process calls from a SendMessage handler,
+            // see http://support.microsoft.com/kb/131056.
+            if (vboxGlobal().isSeparateProcess() && InSendMessage())
+            {
+                PostMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
+                fResult = true;
+                break;
+            }
+
             /* Check for our own special flag to ignore this event.
              * That flag could only be set later in this function
              * so having it here means this event came here
@@ -1768,7 +1778,7 @@ bool UIKeyboardHandler::eventFilter(QObject *pWatchedObject, QEvent *pEvent)
             {
                 /* Release the mouse button grab.
                  * We do not check for failure as we do not currently implement a back-up plan. */
-                xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_1,
+                xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_ANY,
                                           QX11Info::appRootWindow(), XCB_MOD_MASK_ANY);
 
                 break;
@@ -1780,7 +1790,7 @@ bool UIKeyboardHandler::eventFilter(QObject *pWatchedObject, QEvent *pEvent)
                 if (m_fIsKeyboardCaptured)
                     xcb_grab_button_checked(QX11Info::connection(), 0, QX11Info::appRootWindow(),
                                             XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
-                                            XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, XCB_MOD_MASK_ANY);
+                                            XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY);
 
                 break;
             }
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp b/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
index 467a331..3a3ca14 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
@@ -1916,6 +1916,10 @@ bool UIMachineView::nativeEventPreprocessor(const QByteArray &eventType, void *p
 
     switch (::GetEventClass(event))
     {
+        // Keep in mind that this stuff should not be enabled while we are still using
+        // own native keyboard filter installed through cocoa API, to be reworked.
+        // S.a. registerForNativeEvents call in UIKeyboardHandler implementation.
+#if 0
         /* Watch for keyboard-events: */
         case kEventClassKeyboard:
         {
@@ -1935,6 +1939,7 @@ bool UIMachineView::nativeEventPreprocessor(const QByteArray &eventType, void *p
             }
             break;
         }
+#endif
         /* Watch for mouse-events: */
         case kEventClassMouse:
         {
@@ -1972,15 +1977,6 @@ bool UIMachineView::nativeEventPreprocessor(const QByteArray &eventType, void *p
         case WM_SYSKEYUP:
         {
             // WORKAROUND:
-            // Can't do COM inter-process calls from a SendMessage handler,
-            // see http://support.microsoft.com/kb/131056.
-            if (vboxGlobal().isSeparateProcess() && InSendMessage())
-            {
-                PostMessage(pEvent->hwnd, pEvent->message, pEvent->wParam, pEvent->lParam);
-                return true;
-            }
-
-            // WORKAROUND:
             // There is an issue in the Windows Qt5 event processing sequence
             // causing QAbstractNativeEventFilter to receive Windows native events
             // coming not just to the top-level window but to actual target as well.
diff --git a/src/VBox/GuestHost/OpenGL/error/error.py b/src/VBox/GuestHost/OpenGL/error/error.py
old mode 100644
new mode 100755
index b5d4507..7f3da03
--- a/src/VBox/GuestHost/OpenGL/error/error.py
+++ b/src/VBox/GuestHost/OpenGL/error/error.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -11,7 +12,7 @@ import apiutil
 apiutil.CopyrightC()
 
 
-print """#include <stdio.h>
+print("""#include <stdio.h>
 #include "cr_error.h"
 #include "cr_spu.h"
 #include "state/cr_statetypes.h"
@@ -22,7 +23,7 @@ print """#include <stdio.h>
 #define ERROR_APIENTRY
 #endif
 
-#define ERROR_UNUSED(x) ((void)x)"""
+#define ERROR_UNUSED(x) ((void)x)""")
 
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
@@ -30,19 +31,19 @@ keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
-	print '\nstatic %s ERROR_APIENTRY error%s( %s )' % (return_type, func_name, apiutil.MakeDeclarationString(params ))
-	print '{'
+	print('\nstatic %s ERROR_APIENTRY error%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params )))
+	print('{')
 	# Handle the void parameter list
 	for (name, type, vecSize) in params:
-		print '\tERROR_UNUSED(%s);' % name
-	print '\tcrError( "ERROR SPU: Unsupported function gl%s called!" );' % func_name
+		print('\tERROR_UNUSED(%s);' % name)
+	print('\tcrError("ERROR SPU: Unsupported function gl%s called!");' % func_name)
 	if return_type != "void":
-		print '\treturn (%s)0;' % return_type
-	print '}'
+		print('\treturn (%s)0;' % return_type)
+	print('}')
 
-print 'SPUNamedFunctionTable _cr_error_table[] = {'
+print('SPUNamedFunctionTable _cr_error_table[] = {')
 for index in range(len(keys)):
 	func_name = keys[index]
-	print '\t{ "%s", (SPUGenericFunction) error%s },' % (func_name, func_name )
-print '\t{ NULL, NULL }'
-print '};'
+	print('\t{ "%s", (SPUGenericFunction) error%s },' % (func_name, func_name ))
+print('\t{ NULL, NULL }')
+print('};')
diff --git a/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py b/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py
index bce38f1..12d1122 100755
--- a/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py
+++ b/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py
@@ -5,24 +5,25 @@
 # This file defines a bunch of utility functions for OpenGL API code
 # generation.
 
+from __future__ import print_function
 import sys, string, re
 
 
 #======================================================================
 
 def CopyrightC( ):
-	print """/* Copyright (c) 2001, Stanford University
+	print("""/* Copyright (c) 2001, Stanford University
 	All rights reserved.
 
 	See the file LICENSE.txt for information on redistributing this software. */
-	"""
+	""")
 
 def CopyrightDef( ):
-	print """; Copyright (c) 2001, Stanford University
+	print("""; Copyright (c) 2001, Stanford University
 	; All rights reserved.
 	;
 	; See the file LICENSE.txt for information on redistributing this software.
-	"""
+	""")
 
 
 
@@ -55,7 +56,7 @@ def ProcessSpecFile(filename, userFunc):
 	processed."""
 	specFile = open(filename, "r")
 	if not specFile:
-		print "Error: couldn't open %s file!" % filename
+		print("Error: couldn't open %s file!" % filename)
 		sys.exit()
 
 	record = APIFunction()
@@ -63,7 +64,7 @@ def ProcessSpecFile(filename, userFunc):
 	for line in specFile.readlines():
 
 		# split line into tokens
-		tokens = string.split(line)
+		tokens = line.split()
 
 		if len(tokens) > 0 and line[0] != '#':
 
@@ -77,11 +78,11 @@ def ProcessSpecFile(filename, userFunc):
 				record.name = tokens[1]
 
 			elif tokens[0] == 'return':
-				record.returnType = string.join(tokens[1:], ' ')
+				record.returnType = ' '.join(tokens[1:])
 			
 			elif tokens[0] == 'param':
 				name = tokens[1]
-				type = string.join(tokens[2:], ' ')
+				type = ' '.join(tokens[2:])
 				vecSize = 0
 				record.params.append((name, type, vecSize))
 
@@ -166,7 +167,7 @@ def ProcessSpecFile(filename, userFunc):
 				record.chrelopcode = int(tokens[1])
 
 			else:
-				print 'Invalid token %s after function %s' % (tokens[0], record.name)
+				print('Invalid token %s after function %s' % (tokens[0], record.name))
 			#endif
 		#endif
 	#endfor
@@ -188,7 +189,7 @@ __ReverseAliases = {}
 
 
 def AddFunction(record):
-	assert not __FunctionDict.has_key(record.name)
+	assert record.name not in __FunctionDict
 	#if not "omit" in record.chromium:
 	__FunctionDict[record.name] = record
 
@@ -209,9 +210,10 @@ def GetFunctionDict(specFile = ""):
 			# and look for regular aliases (for glloader)
 			a = __FunctionDict[func].alias
 			if a:
-				__ReverseAliases[a] = func
-			#endif
-		#endfor
+				if a in __ReverseAliases:
+					__ReverseAliases[a].append(func)
+				else:
+					__ReverseAliases[a] = [func]
 	#endif
 	return __FunctionDict
 
@@ -335,13 +337,19 @@ def Alias(funcName):
 	return d[funcName].alias
 
 
-def ReverseAlias(funcName):
-	"""Like Alias(), but the inverse."""
+def ReverseAliases(funcName):
+	"""Return a list of aliases."""
 	d = GetFunctionDict()
-	if funcName in __ReverseAliases.keys():
-		return __ReverseAliases[funcName]
+	if funcName in __ReverseAliases:
+		return sorted(__ReverseAliases[funcName])
 	else:
-		return ''
+		return []
+
+
+def ReverseAliasesMaxCount():
+	"""Returns the maximum number of aliases possible for a function."""
+	d = GetFunctionDict()
+	return max([len(a) for a in __ReverseAliases.values()])
 
 
 def NonVectorFunction(funcName):
@@ -382,10 +390,10 @@ def GetCategoryWrapper(func_name):
 		  cat == '2.0' or
 		  cat == '2.1'):
 		# i.e. OpenGL 1.3 or 1.4 or 1.5
-		return "OPENGL_VERSION_" + string.replace(cat, ".", "_")
+		return "OPENGL_VERSION_" + cat.replace(".", "_")
 	else:
 		assert cat != ''
-		return string.replace(cat, "GL_", "")
+		return cat.replace("GL_", "")
 
 
 def CanCompile(funcName):
@@ -517,7 +525,7 @@ def FuncGetsState(funcName):
 
 def IsPointer(dataType):
 	"""Determine if the datatype is a pointer.  Return 1 or 0."""
-	if string.find(dataType, "*") == -1:
+	if dataType.find("*") == -1:
 		return 0
 	else:
 		return 1
@@ -527,7 +535,7 @@ def PointerType(pointerType):
 	"""Return the type of a pointer.
 	Ex: PointerType('const GLubyte *') = 'GLubyte'
 	"""
-	t = string.split(pointerType, ' ')
+	t = pointerType.split(' ')
 	if t[0] == "const":
 		t[0] = t[1]
 	return t[0]
@@ -537,12 +545,12 @@ def PointerType(pointerType):
 
 def OpcodeName(funcName):
 	"""Return the C token for the opcode for the given function."""
-	return "CR_" + string.upper(funcName) + "_OPCODE"
+	return "CR_" + funcName.upper() + "_OPCODE"
 
 
 def ExtendedOpcodeName(funcName):
 	"""Return the C token for the extended opcode for the given function."""
-	return "CR_" + string.upper(funcName) + "_EXTEND_OPCODE"
+	return "CR_" + funcName.upper() + "_EXTEND_OPCODE"
 
 
 
@@ -682,7 +690,7 @@ def PacketLength( params ):
 		if IsPointer(type):
 			size = PointerSize()
 		else:
-			assert string.find(type, "const") == -1
+			assert type.find("const") == -1
 			size = sizeof(type)
 		len = FixAlignment( len, size ) + size
 	len = WordAlign( len )
@@ -705,7 +713,7 @@ def LoadSpecials( filename ):
 #			return {}
 	
 	for line in f.readlines():
-		line = string.strip(line)
+		line = line.strip()
 		if line == "" or line[0] == '#':
 			continue
 		table[line] = 1
@@ -739,23 +747,8 @@ def AllSpecials( table_file ):
 	except KeyError:
 		table = LoadSpecials( filename )
 	
-	keys = table.keys()
-	keys.sort()
-	return keys
-
+	return sorted(table.keys())
 
-def AllSpecials( table_file ):
-	filename = table_file + "_special"
-	table = {}
-	try:
-		table = __specials[filename]
-	except KeyError:
-		table = LoadSpecials(filename)
-	
-	ret = table.keys()
-	ret.sort()
-	return ret
-	
 
 def NumSpecials( table_file ):
 	filename = table_file + "_special"
@@ -772,9 +765,9 @@ def PrintRecord(record):
 		prefix = "cr"
 	else:
 		prefix = "gl"
-	print '%s %s%s(%s);' % (record.returnType, prefix, record.name, argList )
+	print('%s %s%s(%s);' % (record.returnType, prefix, record.name, argList ))
 	if len(record.props) > 0:
-		print '   /* %s */' % string.join(record.props, ' ')
+		print('   /* %s */' % string.join(record.props, ' '))
 
 #ProcessSpecFile("APIspec.txt", PrintRecord)
 
diff --git a/src/VBox/GuestHost/OpenGL/packer/opcodes.py b/src/VBox/GuestHost/OpenGL/packer/opcodes.py
old mode 100644
new mode 100755
index acde780..798ca67
--- a/src/VBox/GuestHost/OpenGL/packer/opcodes.py
+++ b/src/VBox/GuestHost/OpenGL/packer/opcodes.py
@@ -5,8 +5,8 @@
 
 # This script generates include/cr_opcodes.h from the gl_header.parsed file.
 
+from __future__ import print_function
 import sys;
-import cPickle;
 import string;
 import re;
 
@@ -14,33 +14,33 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print ""
-print "/* DO NOT EDIT - THIS FILE GENERATED BY THE opcodes.py SCRIPT */"
-print ""
-print "#ifndef CR_OPCODES_H"
-print "#define CR_OPCODES_H"
-print ""
+print("")
+print("/* DO NOT EDIT - THIS FILE GENERATED BY THE opcodes.py SCRIPT */")
+print("")
+print("#ifndef CR_OPCODES_H")
+print("#define CR_OPCODES_H")
+print("")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 assert len(keys) > 0
 
-print "/* Functions with no return value and input-only parameters */"
-print "typedef enum {"
+print("/* Functions with no return value and input-only parameters */")
+print("typedef enum {")
 
 enum_index = 0
 for func in keys:
 	if "pack" in apiutil.ChromiumProps(func):
-		print "\t%s = %d," % ( apiutil.OpcodeName(func), enum_index )
+		print("\t%s = %d," % ( apiutil.OpcodeName(func), enum_index ))
 		enum_index = enum_index + 1
 
-print "\tCR_EXTEND_OPCODE=%d," % enum_index
+print("\tCR_EXTEND_OPCODE=%d," % enum_index)
 enum_index = enum_index + 1
-print "\tCR_CMDBLOCKBEGIN_OPCODE=%d," % enum_index
+print("\tCR_CMDBLOCKBEGIN_OPCODE=%d," % enum_index)
 enum_index = enum_index + 1
-print "\tCR_CMDBLOCKEND_OPCODE=%d," % enum_index
+print("\tCR_CMDBLOCKEND_OPCODE=%d," % enum_index)
 enum_index = enum_index + 1
-print "\tCR_CMDBLOCKFLUSH_OPCODE=%d," % enum_index
-print "\tCR_NOP_OPCODE=255"
+print("\tCR_CMDBLOCKFLUSH_OPCODE=%d," % enum_index)
+print("\tCR_NOP_OPCODE=255")
 if enum_index > 254:
 	# This would have saved Mike some grief if it had been here earlier.
 	print >> sys.stderr, "You have more than 255 opcodes!  You've been adding functions to"
@@ -51,9 +51,9 @@ if enum_index > 254:
 	print >> sys.stderr, "less than 255!  THIS IS A CATASTROPHIC FAILURE, and I WILL NOT CONTINUE!"
 	print >> sys.stderr, "I'm putting an error in the generated header file so you won't miss"
 	print >> sys.stderr, "this even if you're doing a 'make -k.'"
-	print "#error -- more than 255 opcodes!"
+	print("#error -- more than 255 opcodes!")
 	sys.exit(-1)
-print "} CROpcode;\n"
+print("} CROpcode;\n")
 
 # count up number of extended opcode commands
 num_extends = 0
@@ -71,11 +71,11 @@ if num_auto_codes != 304:
 	print >> sys.stderr, "which breaks backwards compatibility"
 	print >> sys.stderr, "if this is really what you want to do, please adjust this script"
 	print >> sys.stderr, "to handle a new auto-generated opcodes count"
-	print "#error -- num_auto_codes should be 304, but is " + str(num_auto_codes)
+	print("#error -- num_auto_codes should be 304, but is " + str(num_auto_codes))
 	sys.exit(-1)
 
-print "/* Functions with a return value or output parameters */"
-print "typedef enum {"
+print("/* Functions with a return value or output parameters */")
+print("typedef enum {")
 
 opcode_index = 0
 enum_index = 0
@@ -86,11 +86,11 @@ for func in keys:
 		chrelopcode = apiutil.ChromiumRelOpCode(func)
 		opcode = -1
 		if chrelopcode >= 0:
-			if not chrelopcode in chrelopcodes.keys():
+			if not chrelopcode in chrelopcodes:
 				chrelopcodes[chrelopcode] = chrelopcode
 			else:
 				print >> sys.stderr, "non-unique chrelopcode: " + str(chrelopcode)
-				print "#error -- non-unique chrelopcode:  " + str(num_auto_codes)
+				print("#error -- non-unique chrelopcode:  " + str(num_auto_codes))
 				sys.exit(-1)
 			opcode = num_auto_codes + chrelopcode
 		else:
@@ -98,9 +98,9 @@ for func in keys:
 			opcode_index = opcode_index + 1
 
 		if enum_index != num_extends-1:
-			print "\t%s = %d," % (opcodeName, opcode )
+			print("\t%s = %d," % (opcodeName, opcode ))
 		else:
-			print "\t%s = %d" % (opcodeName, opcode )
+			print("\t%s = %d" % (opcodeName, opcode ))
 		enum_index = enum_index + 1
-print "} CRExtendOpcode;\n"
-print "#endif /* CR_OPCODES_H */"
+print("} CRExtendOpcode;\n")
+print("#endif /* CR_OPCODES_H */")
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_current.py b/src/VBox/GuestHost/OpenGL/packer/pack_current.py
index 4cd3f00..31d82f3 100755
--- a/src/VBox/GuestHost/OpenGL/packer/pack_current.py
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_current.py
@@ -5,6 +5,7 @@
 
 # This script generates the pack_current.c file.
 
+from __future__ import print_function
 import sys
 sys.path.append( "../glapi_parser" )
 import apiutil
@@ -13,7 +14,7 @@ from pack_currenttypes import *
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE pack_current.py SCRIPT */
 
 #include <memory.h>
@@ -34,33 +35,31 @@ void crPackOffsetCurrentPointers( int offset )
 	GLvertexattrib_p *vertexAttrib = &(pc->current.c.vertexAttrib);
 	GLfogcoord_p    *fogCoord   = &(pc->current.c.fogCoord);
 	int i;
-"""
+""")
 
-for k in current_fns.keys():
+for k in sorted(current_fns.keys()):
 	name = '%s%s' % (k[:1].lower(),k[1:])
-	if current_fns[k].has_key( 'array' ):
-			print '\tfor (i = 0 ; i < %s ; i++)' % current_fns[k]['array']
-			print '\t{'
+	if 'array' in current_fns[k]:
+			print('\tfor (i = 0; i < %s; i++)' % current_fns[k]['array'])
+			print('\t{')
 	for type in current_fns[k]['types']:
 		for size in current_fns[k]['sizes']:
 			indent = ""
 			ptr = "%s->%s%d" % (name, type, size )
-			if current_fns[k].has_key( 'array' ):
+			if 'array' in current_fns[k]:
 				ptr += "[i]"
 				indent = "\t"
-			print "%s\tif ( %s )" % (indent, ptr)
-			print "%s\t{" % indent
-			print "%s\t\t%s += offset;" % (indent, ptr )
-			print "%s\t}" % indent
-	if current_fns[k].has_key( 'array' ):
-		print '\t}'
-print """
+			print("%s\tif (%s)" % (indent, ptr))
+			print("%s\t\t%s += offset;" % (indent, ptr ))
+	if 'array' in current_fns[k]:
+		print('\t}')
+print("""
 }
 
 void crPackNullCurrentPointers( void )
 {
 	CR_GET_PACKER_CONTEXT(pc);
 	CRCurrentStateAttr	*c		= &(pc->current.c);
-"""
-print '\tmemset ( c, 0, sizeof (CRCurrentStateAttr));'
-print "}"
+""")
+print('\tmemset (c, 0, sizeof(CRCurrentStateAttr));')
+print("}")
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py b/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py
index aeaa189..62a9912 100755
--- a/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py
@@ -5,6 +5,7 @@
 
 # This script generates the include/state/cr_currentpointers.h file.
 
+from __future__ import print_function
 import sys
 sys.path.append( "../glapi_parser" )
 import apiutil
@@ -13,40 +14,42 @@ from pack_currenttypes import *
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE pack_currentheader.py SCRIPT */
 
 #ifndef CR_CURRENT_H
 #define CR_CURRENT_H
 
 #include "state/cr_limits.h"
-"""
+""")
 
-for k in current_fns.keys():
+sorted_keys = sorted(current_fns.keys())
+
+for k in sorted_keys:
 	name = k.lower();
-	print "typedef struct {"
-	if current_fns[k].has_key( 'array' ):
-		print "\tconst unsigned char *ptr[%s];" % current_fns[k]['array']
+	print("typedef struct {")
+	if 'array' in current_fns[k]:
+		print("\tconst unsigned char *ptr[%s];" % current_fns[k]['array'])
 	else:
-		print "\tconst unsigned char *ptr;"
+		print("\tconst unsigned char *ptr;")
 	for type in current_fns[k]['types']:
 		for size in current_fns[k]['sizes']:
-			if current_fns[k].has_key( 'array' ):
-				print "\tconst unsigned char *%s%d[%s];" % (type, size, current_fns[k]['array'])
+			if 'array' in current_fns[k]:
+				print("\tconst unsigned char *%s%d[%s];" % (type, size, current_fns[k]['array']))
 			else:
-				print "\tconst unsigned char *%s%d;" % (type, size)
-	print "} GL%s_p;\n" % name
+				print("\tconst unsigned char *%s%d;" % (type, size))
+	print("} GL%s_p;\n" % name)
 
-print "typedef	struct attrs {"
-for k in current_fns.keys():
+print("typedef	struct attrs {")
+for k in sorted_keys:
 	name = k.lower()
 	field = '%s%s' % (k[:1].lower(),k[1:])
-	print "\tGL%s_p %s;" % (name,field)
-print	"	} CRCurrentStateAttr;"
+	print("\tGL%s_p %s;" % (name,field))
+print("	} CRCurrentStateAttr;")
 	
 
-print "typedef struct {"
-print """
+print("typedef struct {")
+print("""
 	CRCurrentStateAttr c;
 	unsigned char *vtx_op;
 	unsigned char *vtx_data;
@@ -60,4 +63,4 @@ print """
 } CRCurrentStatePointers;
 
 #endif /* CR_CURRENT_H */
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_header.py b/src/VBox/GuestHost/OpenGL/packer/pack_header.py
old mode 100644
new mode 100755
index 7c1729b..d86d078
--- a/src/VBox/GuestHost/OpenGL/packer/pack_header.py
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_header.py
@@ -6,6 +6,7 @@
 # This script generates the cr/include/cr_packfunctions.h file from the
 # gl_header.parsed file.
 
+from __future__ import print_function
 import sys
 import string
 
@@ -14,7 +15,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """#ifndef CR_PACKFUNCTIONS_H
+print("""#ifndef CR_PACKFUNCTIONS_H
 #define CR_PACKFUNCTIONS_H
 
 /* DO NOT EDIT - THIS FILE GENERATED BY THE pack_header.py SCRIPT */
@@ -34,7 +35,7 @@ print """#ifndef CR_PACKFUNCTIONS_H
 #ifdef __cplusplus
 extern "C" {
 #endif
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -59,8 +60,8 @@ for func_name in keys:
 		if "get" in apiutil.Properties(func_name):
 			args.append(("writeback", "int *", 0))
 
-		print 'void PACK_APIENTRY crPack%s( %s );' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args))
-		print 'void PACK_APIENTRY crPack%sSWAP( %s );' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args))
+		print('void PACK_APIENTRY crPack%s(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args)))
+		print('void PACK_APIENTRY crPack%sSWAP(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args)))
 
 
 
@@ -75,16 +76,16 @@ for func_name in keys:
 		assert apiutil.ReturnType(func_name) == "void"
 
 		args = apiutil.Parameters(func_name)
-		print 'void PACK_APIENTRY crPack%sBBOX(%s);' % (func_name, apiutil.MakeDeclarationString(args))
-		print 'void PACK_APIENTRY crPack%sBBOX_COUNT(%s);' % (func_name, apiutil.MakeDeclarationString(args))
-		print 'void PACK_APIENTRY crPack%sBBOXSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args))
-		print 'void PACK_APIENTRY crPack%sBBOX_COUNTSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args))
+		print('void PACK_APIENTRY crPack%sBBOX(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
+		print('void PACK_APIENTRY crPack%sBBOX_COUNT(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
+		print('void PACK_APIENTRY crPack%sBBOXSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
+		print('void PACK_APIENTRY crPack%sBBOX_COUNTSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
 
 
-print """
+print("""
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* CR_PACKFUNCTIONS_H */
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_lights.c b/src/VBox/GuestHost/OpenGL/packer/pack_lights.c
index 23171bb..a2c88f9 100644
--- a/src/VBox/GuestHost/OpenGL/packer/pack_lights.c
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_lights.c
@@ -7,49 +7,49 @@
 #include "packer.h"
 #include "cr_error.h"
 
-static GLboolean __handleLightData( GLenum light, GLenum pname, const GLfloat *params )
+static GLboolean __handleLightData(GLenum light, GLenum pname, const GLfloat *params)
 {
     CR_GET_PACKER_CONTEXT(pc);
-    unsigned int packet_length = sizeof( int ) + sizeof( light ) + sizeof( pname );
+    unsigned int packet_length = sizeof(int) + sizeof(light) + sizeof(pname);
     unsigned int params_length = 0;
     unsigned char *data_ptr;
-    switch( pname )
+    switch(pname)
     {
         case GL_AMBIENT:
         case GL_DIFFUSE:
         case GL_SPECULAR:
         case GL_POSITION:
-            params_length = 4*sizeof( *params );
+            params_length = 4*sizeof(*params);
             break;
         case GL_SPOT_DIRECTION:
-            params_length = 3*sizeof( *params );
+            params_length = 3*sizeof(*params);
             break;
         case GL_SPOT_EXPONENT:
         case GL_SPOT_CUTOFF:
         case GL_CONSTANT_ATTENUATION:
         case GL_LINEAR_ATTENUATION:
         case GL_QUADRATIC_ATTENUATION:
-            params_length = sizeof( *params );
+            params_length = sizeof(*params);
             break;
         default:
-            __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                     "crPackLight(bad pname)" );
+            __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                     "crPackLight(bad pname)");
             return GL_FALSE;
     }
     packet_length += params_length;
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, int, packet_length );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, light );
-    WRITE_DATA( sizeof( int ) + 4, GLenum, pname );
-    WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] );
-    if (params_length > sizeof( *params )) 
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, int, packet_length);
+    WRITE_DATA(sizeof(int) + 0, GLenum, light);
+    WRITE_DATA(sizeof(int) + 4, GLenum, pname);
+    WRITE_DATA(sizeof(int) + 8, GLfloat, params[0]);
+    if (params_length > sizeof(*params)) 
     {
-        WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] );
-        WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] );
+        WRITE_DATA(sizeof(int) + 12, GLfloat, params[1]);
+        WRITE_DATA(sizeof(int) + 16, GLfloat, params[2]);
     }
-    if (params_length > 3*sizeof( *params )) 
+    if (params_length > 3*sizeof(*params)) 
     {
-        WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] );
+        WRITE_DATA(sizeof(int) + 20, GLfloat, params[3]);
     }
     return GL_TRUE;
 }
@@ -57,8 +57,8 @@ static GLboolean __handleLightData( GLenum light, GLenum pname, const GLfloat *p
 void PACK_APIENTRY crPackLightfv (GLenum light, GLenum pname, const GLfloat *params)
 {
     CR_GET_PACKER_CONTEXT(pc);
-    if (__handleLightData( light, pname, params ))
-        WRITE_OPCODE( pc, CR_LIGHTFV_OPCODE );
+    if (__handleLightData(light, pname, params))
+        WRITE_OPCODE(pc, CR_LIGHTFV_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -66,41 +66,41 @@ void PACK_APIENTRY crPackLightiv (GLenum light, GLenum pname, const GLint *param
 {
     /* floats and ints are the same size, so the packing should be the same */
     CR_GET_PACKER_CONTEXT(pc);
-    if (__handleLightData( light, pname, (const GLfloat *) params ))
-        WRITE_OPCODE( pc, CR_LIGHTIV_OPCODE );
+    if (__handleLightData(light, pname, (const GLfloat *) params))
+        WRITE_OPCODE(pc, CR_LIGHTIV_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-static GLboolean __handleLightModelData( GLenum pname, const GLfloat *params )
+static GLboolean __handleLightModelData(GLenum pname, const GLfloat *params)
 {
     CR_GET_PACKER_CONTEXT(pc);
-    unsigned int packet_length = sizeof( int ) + sizeof( pname );
+    unsigned int packet_length = sizeof(int) + sizeof(pname);
     unsigned int params_length = 0;
     unsigned char *data_ptr;
-    switch( pname )
+    switch(pname)
     {
         case GL_LIGHT_MODEL_AMBIENT:
-            params_length = 4*sizeof( *params );
+            params_length = 4*sizeof(*params);
             break;
         case GL_LIGHT_MODEL_TWO_SIDE:
         case GL_LIGHT_MODEL_LOCAL_VIEWER:
-            params_length = sizeof( *params );
+            params_length = sizeof(*params);
             break;
         default:
-            __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                     "crPackLightModel(bad pname)" );
+            __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                     "crPackLightModel(bad pname)");
             return GL_FALSE;
     }
     packet_length += params_length;
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, int, packet_length );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, pname );
-    WRITE_DATA( sizeof( int ) + 4, GLfloat, params[0] );
-    if (params_length > sizeof( *params ))
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, int, packet_length);
+    WRITE_DATA(sizeof(int) + 0, GLenum, pname);
+    WRITE_DATA(sizeof(int) + 4, GLfloat, params[0]);
+    if (params_length > sizeof(*params))
     {
-        WRITE_DATA( sizeof( int ) + 8, GLfloat, params[1] );
-        WRITE_DATA( sizeof( int ) + 12, GLfloat, params[2] );
-        WRITE_DATA( sizeof( int ) + 16, GLfloat, params[3] );
+        WRITE_DATA(sizeof(int) + 8, GLfloat, params[1]);
+        WRITE_DATA(sizeof(int) + 12, GLfloat, params[2]);
+        WRITE_DATA(sizeof(int) + 16, GLfloat, params[3]);
     }
     return GL_TRUE;
 }
@@ -108,8 +108,8 @@ static GLboolean __handleLightModelData( GLenum pname, const GLfloat *params )
 void PACK_APIENTRY crPackLightModelfv (GLenum pname, const GLfloat *params)
 {
     CR_GET_PACKER_CONTEXT(pc);
-    if (__handleLightModelData( pname, params ))
-        WRITE_OPCODE( pc, CR_LIGHTMODELFV_OPCODE );
+    if (__handleLightModelData(pname, params))
+        WRITE_OPCODE(pc, CR_LIGHTMODELFV_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -117,7 +117,7 @@ void PACK_APIENTRY crPackLightModeliv (GLenum pname, const GLint *params)
 {
     /* floats and ints are the same size, so the packing should be the same */
     CR_GET_PACKER_CONTEXT(pc);
-    if (__handleLightModelData( pname, (const GLfloat *) params ))
-        WRITE_OPCODE( pc, CR_LIGHTMODELIV_OPCODE );
+    if (__handleLightModelData(pname, (const GLfloat *) params))
+        WRITE_OPCODE(pc, CR_LIGHTMODELIV_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c b/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c
index 971dd98..b16857a 100644
--- a/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c
@@ -7,218 +7,218 @@
 #include "packer.h"
 #include "cr_opcodes.h"
 
-void PACK_APIENTRY crPackMultMatrixd( const GLdouble *m )
+void PACK_APIENTRY crPackMultMatrixd(const GLdouble *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m );
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DOUBLE( 0*sizeof(double), m[ 0] );
-    WRITE_DOUBLE( 1*sizeof(double), m[ 1] );
-    WRITE_DOUBLE( 2*sizeof(double), m[ 2] );
-    WRITE_DOUBLE( 3*sizeof(double), m[ 3] );
-    WRITE_DOUBLE( 4*sizeof(double), m[ 4] );
-    WRITE_DOUBLE( 5*sizeof(double), m[ 5] );
-    WRITE_DOUBLE( 6*sizeof(double), m[ 6] );
-    WRITE_DOUBLE( 7*sizeof(double), m[ 7] );
-    WRITE_DOUBLE( 8*sizeof(double), m[ 8] );
-    WRITE_DOUBLE( 9*sizeof(double), m[ 9] );
-    WRITE_DOUBLE( 10*sizeof(double), m[10] );
-    WRITE_DOUBLE( 11*sizeof(double), m[11] );
-    WRITE_DOUBLE( 12*sizeof(double), m[12] );
-    WRITE_DOUBLE( 13*sizeof(double), m[13] );
-    WRITE_DOUBLE( 14*sizeof(double), m[14] );
-    WRITE_DOUBLE( 15*sizeof(double), m[15] );
-    WRITE_OPCODE( pc, CR_MULTMATRIXD_OPCODE );
+    int packet_length = 16*sizeof(*m);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DOUBLE(0*sizeof(double), m[ 0]);
+    WRITE_DOUBLE(1*sizeof(double), m[ 1]);
+    WRITE_DOUBLE(2*sizeof(double), m[ 2]);
+    WRITE_DOUBLE(3*sizeof(double), m[ 3]);
+    WRITE_DOUBLE(4*sizeof(double), m[ 4]);
+    WRITE_DOUBLE(5*sizeof(double), m[ 5]);
+    WRITE_DOUBLE(6*sizeof(double), m[ 6]);
+    WRITE_DOUBLE(7*sizeof(double), m[ 7]);
+    WRITE_DOUBLE(8*sizeof(double), m[ 8]);
+    WRITE_DOUBLE(9*sizeof(double), m[ 9]);
+    WRITE_DOUBLE(10*sizeof(double), m[10]);
+    WRITE_DOUBLE(11*sizeof(double), m[11]);
+    WRITE_DOUBLE(12*sizeof(double), m[12]);
+    WRITE_DOUBLE(13*sizeof(double), m[13]);
+    WRITE_DOUBLE(14*sizeof(double), m[14]);
+    WRITE_DOUBLE(15*sizeof(double), m[15]);
+    WRITE_OPCODE(pc, CR_MULTMATRIXD_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackMultMatrixf( const GLfloat *m )
+void PACK_APIENTRY crPackMultMatrixf(const GLfloat *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m );
-    CR_GET_BUFFERED_POINTER(pc, packet_length ); 
-    WRITE_DATA( 0*sizeof(GLfloat), GLfloat, m[ 0] );
-    WRITE_DATA( 1*sizeof(GLfloat), GLfloat, m[ 1] );
-    WRITE_DATA( 2*sizeof(GLfloat), GLfloat, m[ 2] );
-    WRITE_DATA( 3*sizeof(GLfloat), GLfloat, m[ 3] );
-    WRITE_DATA( 4*sizeof(GLfloat), GLfloat, m[ 4] );
-    WRITE_DATA( 5*sizeof(GLfloat), GLfloat, m[ 5] );
-    WRITE_DATA( 6*sizeof(GLfloat), GLfloat, m[ 6] );
-    WRITE_DATA( 7*sizeof(GLfloat), GLfloat, m[ 7] );
-    WRITE_DATA( 8*sizeof(GLfloat), GLfloat, m[ 8] );
-    WRITE_DATA( 9*sizeof(GLfloat), GLfloat, m[ 9] );
-    WRITE_DATA( 10*sizeof(GLfloat), GLfloat, m[10] );
-    WRITE_DATA( 11*sizeof(GLfloat), GLfloat, m[11] );
-    WRITE_DATA( 12*sizeof(GLfloat), GLfloat, m[12] );
-    WRITE_DATA( 13*sizeof(GLfloat), GLfloat, m[13] );
-    WRITE_DATA( 14*sizeof(GLfloat), GLfloat, m[14] );
-    WRITE_DATA( 15*sizeof(GLfloat), GLfloat, m[15] );
-    WRITE_OPCODE( pc, CR_MULTMATRIXF_OPCODE );
+    int packet_length = 16*sizeof(*m);
+    CR_GET_BUFFERED_POINTER(pc, packet_length); 
+    WRITE_DATA(0*sizeof(GLfloat), GLfloat, m[ 0]);
+    WRITE_DATA(1*sizeof(GLfloat), GLfloat, m[ 1]);
+    WRITE_DATA(2*sizeof(GLfloat), GLfloat, m[ 2]);
+    WRITE_DATA(3*sizeof(GLfloat), GLfloat, m[ 3]);
+    WRITE_DATA(4*sizeof(GLfloat), GLfloat, m[ 4]);
+    WRITE_DATA(5*sizeof(GLfloat), GLfloat, m[ 5]);
+    WRITE_DATA(6*sizeof(GLfloat), GLfloat, m[ 6]);
+    WRITE_DATA(7*sizeof(GLfloat), GLfloat, m[ 7]);
+    WRITE_DATA(8*sizeof(GLfloat), GLfloat, m[ 8]);
+    WRITE_DATA(9*sizeof(GLfloat), GLfloat, m[ 9]);
+    WRITE_DATA(10*sizeof(GLfloat), GLfloat, m[10]);
+    WRITE_DATA(11*sizeof(GLfloat), GLfloat, m[11]);
+    WRITE_DATA(12*sizeof(GLfloat), GLfloat, m[12]);
+    WRITE_DATA(13*sizeof(GLfloat), GLfloat, m[13]);
+    WRITE_DATA(14*sizeof(GLfloat), GLfloat, m[14]);
+    WRITE_DATA(15*sizeof(GLfloat), GLfloat, m[15]);
+    WRITE_OPCODE(pc, CR_MULTMATRIXF_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackLoadMatrixd( const GLdouble *m )
+void PACK_APIENTRY crPackLoadMatrixd(const GLdouble *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m );
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DOUBLE( 0*sizeof(double), m[ 0] );
-    WRITE_DOUBLE( 1*sizeof(double), m[ 1] );
-    WRITE_DOUBLE( 2*sizeof(double), m[ 2] );
-    WRITE_DOUBLE( 3*sizeof(double), m[ 3] );
-    WRITE_DOUBLE( 4*sizeof(double), m[ 4] );
-    WRITE_DOUBLE( 5*sizeof(double), m[ 5] );
-    WRITE_DOUBLE( 6*sizeof(double), m[ 6] );
-    WRITE_DOUBLE( 7*sizeof(double), m[ 7] );
-    WRITE_DOUBLE( 8*sizeof(double), m[ 8] );
-    WRITE_DOUBLE( 9*sizeof(double), m[ 9] );
-    WRITE_DOUBLE( 10*sizeof(double), m[10] );
-    WRITE_DOUBLE( 11*sizeof(double), m[11] );
-    WRITE_DOUBLE( 12*sizeof(double), m[12] );
-    WRITE_DOUBLE( 13*sizeof(double), m[13] );
-    WRITE_DOUBLE( 14*sizeof(double), m[14] );
-    WRITE_DOUBLE( 15*sizeof(double), m[15] );
-    WRITE_OPCODE( pc, CR_LOADMATRIXD_OPCODE );
+    int packet_length = 16*sizeof(*m);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DOUBLE(0*sizeof(double), m[ 0]);
+    WRITE_DOUBLE(1*sizeof(double), m[ 1]);
+    WRITE_DOUBLE(2*sizeof(double), m[ 2]);
+    WRITE_DOUBLE(3*sizeof(double), m[ 3]);
+    WRITE_DOUBLE(4*sizeof(double), m[ 4]);
+    WRITE_DOUBLE(5*sizeof(double), m[ 5]);
+    WRITE_DOUBLE(6*sizeof(double), m[ 6]);
+    WRITE_DOUBLE(7*sizeof(double), m[ 7]);
+    WRITE_DOUBLE(8*sizeof(double), m[ 8]);
+    WRITE_DOUBLE(9*sizeof(double), m[ 9]);
+    WRITE_DOUBLE(10*sizeof(double), m[10]);
+    WRITE_DOUBLE(11*sizeof(double), m[11]);
+    WRITE_DOUBLE(12*sizeof(double), m[12]);
+    WRITE_DOUBLE(13*sizeof(double), m[13]);
+    WRITE_DOUBLE(14*sizeof(double), m[14]);
+    WRITE_DOUBLE(15*sizeof(double), m[15]);
+    WRITE_OPCODE(pc, CR_LOADMATRIXD_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackLoadMatrixf( const GLfloat *m )
+void PACK_APIENTRY crPackLoadMatrixf(const GLfloat *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m );
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0*sizeof(GLfloat), GLfloat, m[ 0] );
-    WRITE_DATA( 1*sizeof(GLfloat), GLfloat, m[ 1] );
-    WRITE_DATA( 2*sizeof(GLfloat), GLfloat, m[ 2] );
-    WRITE_DATA( 3*sizeof(GLfloat), GLfloat, m[ 3] );
-    WRITE_DATA( 4*sizeof(GLfloat), GLfloat, m[ 4] );
-    WRITE_DATA( 5*sizeof(GLfloat), GLfloat, m[ 5] );
-    WRITE_DATA( 6*sizeof(GLfloat), GLfloat, m[ 6] );
-    WRITE_DATA( 7*sizeof(GLfloat), GLfloat, m[ 7] );
-    WRITE_DATA( 8*sizeof(GLfloat), GLfloat, m[ 8] );
-    WRITE_DATA( 9*sizeof(GLfloat), GLfloat, m[ 9] );
-    WRITE_DATA( 10*sizeof(GLfloat), GLfloat, m[10] );
-    WRITE_DATA( 11*sizeof(GLfloat), GLfloat, m[11] );
-    WRITE_DATA( 12*sizeof(GLfloat), GLfloat, m[12] );
-    WRITE_DATA( 13*sizeof(GLfloat), GLfloat, m[13] );
-    WRITE_DATA( 14*sizeof(GLfloat), GLfloat, m[14] );
-    WRITE_DATA( 15*sizeof(GLfloat), GLfloat, m[15] );
-    WRITE_OPCODE( pc, CR_LOADMATRIXF_OPCODE );
+    int packet_length = 16*sizeof(*m);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0*sizeof(GLfloat), GLfloat, m[ 0]);
+    WRITE_DATA(1*sizeof(GLfloat), GLfloat, m[ 1]);
+    WRITE_DATA(2*sizeof(GLfloat), GLfloat, m[ 2]);
+    WRITE_DATA(3*sizeof(GLfloat), GLfloat, m[ 3]);
+    WRITE_DATA(4*sizeof(GLfloat), GLfloat, m[ 4]);
+    WRITE_DATA(5*sizeof(GLfloat), GLfloat, m[ 5]);
+    WRITE_DATA(6*sizeof(GLfloat), GLfloat, m[ 6]);
+    WRITE_DATA(7*sizeof(GLfloat), GLfloat, m[ 7]);
+    WRITE_DATA(8*sizeof(GLfloat), GLfloat, m[ 8]);
+    WRITE_DATA(9*sizeof(GLfloat), GLfloat, m[ 9]);
+    WRITE_DATA(10*sizeof(GLfloat), GLfloat, m[10]);
+    WRITE_DATA(11*sizeof(GLfloat), GLfloat, m[11]);
+    WRITE_DATA(12*sizeof(GLfloat), GLfloat, m[12]);
+    WRITE_DATA(13*sizeof(GLfloat), GLfloat, m[13]);
+    WRITE_DATA(14*sizeof(GLfloat), GLfloat, m[14]);
+    WRITE_DATA(15*sizeof(GLfloat), GLfloat, m[15]);
+    WRITE_OPCODE(pc, CR_LOADMATRIXF_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackMultTransposeMatrixdARB( const GLdouble *m )
+void PACK_APIENTRY crPackMultTransposeMatrixdARB(const GLdouble *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum);
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, GLint, packet_length );
-    WRITE_DATA( 4, GLenum, CR_MULTTRANSPOSEMATRIXDARB_EXTEND_OPCODE );
-    WRITE_DOUBLE( 8 + 0*sizeof(double), m[ 0] );
-    WRITE_DOUBLE( 8 + 1*sizeof(double), m[ 1] );
-    WRITE_DOUBLE( 8 + 2*sizeof(double), m[ 2] );
-    WRITE_DOUBLE( 8 + 3*sizeof(double), m[ 3] );
-    WRITE_DOUBLE( 8 + 4*sizeof(double), m[ 4] );
-    WRITE_DOUBLE( 8 + 5*sizeof(double), m[ 5] );
-    WRITE_DOUBLE( 8 + 6*sizeof(double), m[ 6] );
-    WRITE_DOUBLE( 8 + 7*sizeof(double), m[ 7] );
-    WRITE_DOUBLE( 8 + 8*sizeof(double), m[ 8] );
-    WRITE_DOUBLE( 8 + 9*sizeof(double), m[ 9] );
-    WRITE_DOUBLE( 8 + 10*sizeof(double), m[10] );
-    WRITE_DOUBLE( 8 + 11*sizeof(double), m[11] );
-    WRITE_DOUBLE( 8 + 12*sizeof(double), m[12] );
-    WRITE_DOUBLE( 8 + 13*sizeof(double), m[13] );
-    WRITE_DOUBLE( 8 + 14*sizeof(double), m[14] );
-    WRITE_DOUBLE( 8 + 15*sizeof(double), m[15] );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, GLint, packet_length);
+    WRITE_DATA(4, GLenum, CR_MULTTRANSPOSEMATRIXDARB_EXTEND_OPCODE);
+    WRITE_DOUBLE(8 + 0*sizeof(double), m[ 0]);
+    WRITE_DOUBLE(8 + 1*sizeof(double), m[ 1]);
+    WRITE_DOUBLE(8 + 2*sizeof(double), m[ 2]);
+    WRITE_DOUBLE(8 + 3*sizeof(double), m[ 3]);
+    WRITE_DOUBLE(8 + 4*sizeof(double), m[ 4]);
+    WRITE_DOUBLE(8 + 5*sizeof(double), m[ 5]);
+    WRITE_DOUBLE(8 + 6*sizeof(double), m[ 6]);
+    WRITE_DOUBLE(8 + 7*sizeof(double), m[ 7]);
+    WRITE_DOUBLE(8 + 8*sizeof(double), m[ 8]);
+    WRITE_DOUBLE(8 + 9*sizeof(double), m[ 9]);
+    WRITE_DOUBLE(8 + 10*sizeof(double), m[10]);
+    WRITE_DOUBLE(8 + 11*sizeof(double), m[11]);
+    WRITE_DOUBLE(8 + 12*sizeof(double), m[12]);
+    WRITE_DOUBLE(8 + 13*sizeof(double), m[13]);
+    WRITE_DOUBLE(8 + 14*sizeof(double), m[14]);
+    WRITE_DOUBLE(8 + 15*sizeof(double), m[15]);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackMultTransposeMatrixfARB( const GLfloat *m )
+void PACK_APIENTRY crPackMultTransposeMatrixfARB(const GLfloat *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum);
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, GLint, packet_length );
-    WRITE_DATA( 4, GLenum, CR_MULTTRANSPOSEMATRIXFARB_EXTEND_OPCODE );
-    WRITE_DATA( 8 + 0*sizeof(GLfloat), GLfloat, m[ 0] );
-    WRITE_DATA( 8 + 1*sizeof(GLfloat), GLfloat, m[ 1] );
-    WRITE_DATA( 8 + 2*sizeof(GLfloat), GLfloat, m[ 2] );
-    WRITE_DATA( 8 + 3*sizeof(GLfloat), GLfloat, m[ 3] );
-    WRITE_DATA( 8 + 4*sizeof(GLfloat), GLfloat, m[ 4] );
-    WRITE_DATA( 8 + 5*sizeof(GLfloat), GLfloat, m[ 5] );
-    WRITE_DATA( 8 + 6*sizeof(GLfloat), GLfloat, m[ 6] );
-    WRITE_DATA( 8 + 7*sizeof(GLfloat), GLfloat, m[ 7] );
-    WRITE_DATA( 8 + 8*sizeof(GLfloat), GLfloat, m[ 8] );
-    WRITE_DATA( 8 + 9*sizeof(GLfloat), GLfloat, m[ 9] );
-    WRITE_DATA( 8 + 10*sizeof(GLfloat), GLfloat, m[10] );
-    WRITE_DATA( 8 + 11*sizeof(GLfloat), GLfloat, m[11] );
-    WRITE_DATA( 8 + 12*sizeof(GLfloat), GLfloat, m[12] );
-    WRITE_DATA( 8 + 13*sizeof(GLfloat), GLfloat, m[13] );
-    WRITE_DATA( 8 + 14*sizeof(GLfloat), GLfloat, m[14] );
-    WRITE_DATA( 8 + 15*sizeof(GLfloat), GLfloat, m[15] );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, GLint, packet_length);
+    WRITE_DATA(4, GLenum, CR_MULTTRANSPOSEMATRIXFARB_EXTEND_OPCODE);
+    WRITE_DATA(8 + 0*sizeof(GLfloat), GLfloat, m[ 0]);
+    WRITE_DATA(8 + 1*sizeof(GLfloat), GLfloat, m[ 1]);
+    WRITE_DATA(8 + 2*sizeof(GLfloat), GLfloat, m[ 2]);
+    WRITE_DATA(8 + 3*sizeof(GLfloat), GLfloat, m[ 3]);
+    WRITE_DATA(8 + 4*sizeof(GLfloat), GLfloat, m[ 4]);
+    WRITE_DATA(8 + 5*sizeof(GLfloat), GLfloat, m[ 5]);
+    WRITE_DATA(8 + 6*sizeof(GLfloat), GLfloat, m[ 6]);
+    WRITE_DATA(8 + 7*sizeof(GLfloat), GLfloat, m[ 7]);
+    WRITE_DATA(8 + 8*sizeof(GLfloat), GLfloat, m[ 8]);
+    WRITE_DATA(8 + 9*sizeof(GLfloat), GLfloat, m[ 9]);
+    WRITE_DATA(8 + 10*sizeof(GLfloat), GLfloat, m[10]);
+    WRITE_DATA(8 + 11*sizeof(GLfloat), GLfloat, m[11]);
+    WRITE_DATA(8 + 12*sizeof(GLfloat), GLfloat, m[12]);
+    WRITE_DATA(8 + 13*sizeof(GLfloat), GLfloat, m[13]);
+    WRITE_DATA(8 + 14*sizeof(GLfloat), GLfloat, m[14]);
+    WRITE_DATA(8 + 15*sizeof(GLfloat), GLfloat, m[15]);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackLoadTransposeMatrixdARB( const GLdouble *m )
+void PACK_APIENTRY crPackLoadTransposeMatrixdARB(const GLdouble *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum);
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, GLint, packet_length );
-    WRITE_DATA( 4, GLenum, CR_LOADTRANSPOSEMATRIXDARB_EXTEND_OPCODE );
-    WRITE_DOUBLE( 8 + 0*sizeof(double), m[ 0] );
-    WRITE_DOUBLE( 8 + 1*sizeof(double), m[ 1] );
-    WRITE_DOUBLE( 8 + 2*sizeof(double), m[ 2] );
-    WRITE_DOUBLE( 8 + 3*sizeof(double), m[ 3] );
-    WRITE_DOUBLE( 8 + 4*sizeof(double), m[ 4] );
-    WRITE_DOUBLE( 8 + 5*sizeof(double), m[ 5] );
-    WRITE_DOUBLE( 8 + 6*sizeof(double), m[ 6] );
-    WRITE_DOUBLE( 8 + 7*sizeof(double), m[ 7] );
-    WRITE_DOUBLE( 8 + 8*sizeof(double), m[ 8] );
-    WRITE_DOUBLE( 8 + 9*sizeof(double), m[ 9] );
-    WRITE_DOUBLE( 8 + 10*sizeof(double), m[10] );
-    WRITE_DOUBLE( 8 + 11*sizeof(double), m[11] );
-    WRITE_DOUBLE( 8 + 12*sizeof(double), m[12] );
-    WRITE_DOUBLE( 8 + 13*sizeof(double), m[13] );
-    WRITE_DOUBLE( 8 + 14*sizeof(double), m[14] );
-    WRITE_DOUBLE( 8 + 15*sizeof(double), m[15] );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, GLint, packet_length);
+    WRITE_DATA(4, GLenum, CR_LOADTRANSPOSEMATRIXDARB_EXTEND_OPCODE);
+    WRITE_DOUBLE(8 + 0*sizeof(double), m[ 0]);
+    WRITE_DOUBLE(8 + 1*sizeof(double), m[ 1]);
+    WRITE_DOUBLE(8 + 2*sizeof(double), m[ 2]);
+    WRITE_DOUBLE(8 + 3*sizeof(double), m[ 3]);
+    WRITE_DOUBLE(8 + 4*sizeof(double), m[ 4]);
+    WRITE_DOUBLE(8 + 5*sizeof(double), m[ 5]);
+    WRITE_DOUBLE(8 + 6*sizeof(double), m[ 6]);
+    WRITE_DOUBLE(8 + 7*sizeof(double), m[ 7]);
+    WRITE_DOUBLE(8 + 8*sizeof(double), m[ 8]);
+    WRITE_DOUBLE(8 + 9*sizeof(double), m[ 9]);
+    WRITE_DOUBLE(8 + 10*sizeof(double), m[10]);
+    WRITE_DOUBLE(8 + 11*sizeof(double), m[11]);
+    WRITE_DOUBLE(8 + 12*sizeof(double), m[12]);
+    WRITE_DOUBLE(8 + 13*sizeof(double), m[13]);
+    WRITE_DOUBLE(8 + 14*sizeof(double), m[14]);
+    WRITE_DOUBLE(8 + 15*sizeof(double), m[15]);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackLoadTransposeMatrixfARB( const GLfloat *m )
+void PACK_APIENTRY crPackLoadTransposeMatrixfARB(const GLfloat *m)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum);
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, GLint, packet_length );
-    WRITE_DATA( 4, GLenum, CR_LOADTRANSPOSEMATRIXFARB_EXTEND_OPCODE );
-    WRITE_DATA( 8 + 0*sizeof(GLfloat), GLfloat, m[ 0] );
-    WRITE_DATA( 8 + 1*sizeof(GLfloat), GLfloat, m[ 1] );
-    WRITE_DATA( 8 + 2*sizeof(GLfloat), GLfloat, m[ 2] );
-    WRITE_DATA( 8 + 3*sizeof(GLfloat), GLfloat, m[ 3] );
-    WRITE_DATA( 8 + 4*sizeof(GLfloat), GLfloat, m[ 4] );
-    WRITE_DATA( 8 + 5*sizeof(GLfloat), GLfloat, m[ 5] );
-    WRITE_DATA( 8 + 6*sizeof(GLfloat), GLfloat, m[ 6] );
-    WRITE_DATA( 8 + 7*sizeof(GLfloat), GLfloat, m[ 7] );
-    WRITE_DATA( 8 + 8*sizeof(GLfloat), GLfloat, m[ 8] );
-    WRITE_DATA( 8 + 9*sizeof(GLfloat), GLfloat, m[ 9] );
-    WRITE_DATA( 8 + 10*sizeof(GLfloat), GLfloat, m[10] );
-    WRITE_DATA( 8 + 11*sizeof(GLfloat), GLfloat, m[11] );
-    WRITE_DATA( 8 + 12*sizeof(GLfloat), GLfloat, m[12] );
-    WRITE_DATA( 8 + 13*sizeof(GLfloat), GLfloat, m[13] );
-    WRITE_DATA( 8 + 14*sizeof(GLfloat), GLfloat, m[14] );
-    WRITE_DATA( 8 + 15*sizeof(GLfloat), GLfloat, m[15] );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum);
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, GLint, packet_length);
+    WRITE_DATA(4, GLenum, CR_LOADTRANSPOSEMATRIXFARB_EXTEND_OPCODE);
+    WRITE_DATA(8 + 0*sizeof(GLfloat), GLfloat, m[ 0]);
+    WRITE_DATA(8 + 1*sizeof(GLfloat), GLfloat, m[ 1]);
+    WRITE_DATA(8 + 2*sizeof(GLfloat), GLfloat, m[ 2]);
+    WRITE_DATA(8 + 3*sizeof(GLfloat), GLfloat, m[ 3]);
+    WRITE_DATA(8 + 4*sizeof(GLfloat), GLfloat, m[ 4]);
+    WRITE_DATA(8 + 5*sizeof(GLfloat), GLfloat, m[ 5]);
+    WRITE_DATA(8 + 6*sizeof(GLfloat), GLfloat, m[ 6]);
+    WRITE_DATA(8 + 7*sizeof(GLfloat), GLfloat, m[ 7]);
+    WRITE_DATA(8 + 8*sizeof(GLfloat), GLfloat, m[ 8]);
+    WRITE_DATA(8 + 9*sizeof(GLfloat), GLfloat, m[ 9]);
+    WRITE_DATA(8 + 10*sizeof(GLfloat), GLfloat, m[10]);
+    WRITE_DATA(8 + 11*sizeof(GLfloat), GLfloat, m[11]);
+    WRITE_DATA(8 + 12*sizeof(GLfloat), GLfloat, m[12]);
+    WRITE_DATA(8 + 13*sizeof(GLfloat), GLfloat, m[13]);
+    WRITE_DATA(8 + 14*sizeof(GLfloat), GLfloat, m[14]);
+    WRITE_DATA(8 + 15*sizeof(GLfloat), GLfloat, m[15]);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_program.c b/src/VBox/GuestHost/OpenGL/packer/pack_program.c
index b880bf6..3cd0621 100644
--- a/src/VBox/GuestHost/OpenGL/packer/pack_program.c
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_program.c
@@ -14,7 +14,7 @@
 #include "cr_error.h"
 
 
-void PACK_APIENTRY crPackProgramParameters4dvNV (GLenum target, GLuint index, GLuint num, const GLdouble * params)
+void PACK_APIENTRY crPackProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
@@ -32,7 +32,7 @@ void PACK_APIENTRY crPackProgramParameters4dvNV (GLenum target, GLuint index, GL
 }
 
 
-void PACK_APIENTRY crPackProgramParameters4fvNV (GLenum target, GLuint index, GLuint num, const GLfloat * params)
+void PACK_APIENTRY crPackProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
@@ -50,7 +50,7 @@ void PACK_APIENTRY crPackProgramParameters4fvNV (GLenum target, GLuint index, GL
 }
 
 
-void PACK_APIENTRY crPackVertexAttribs1dvNV( GLuint index, GLsizei n, const GLdouble *v )
+void PACK_APIENTRY crPackVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -59,7 +59,7 @@ void PACK_APIENTRY crPackVertexAttribs1dvNV( GLuint index, GLsizei n, const GLdo
 }
 
 
-void PACK_APIENTRY crPackVertexAttribs1fvNV( GLuint index, GLsizei n, const GLfloat *v )
+void PACK_APIENTRY crPackVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -68,7 +68,7 @@ void PACK_APIENTRY crPackVertexAttribs1fvNV( GLuint index, GLsizei n, const GLfl
 }
 
 
-void PACK_APIENTRY crPackVertexAttribs1svNV( GLuint index, GLsizei n, const GLshort *v )
+void PACK_APIENTRY crPackVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -77,7 +77,7 @@ void PACK_APIENTRY crPackVertexAttribs1svNV( GLuint index, GLsizei n, const GLsh
 }
 
 
-void PACK_APIENTRY crPackVertexAttribs2dvNV( GLuint index, GLsizei n, const GLdouble *v )
+void PACK_APIENTRY crPackVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -85,7 +85,7 @@ void PACK_APIENTRY crPackVertexAttribs2dvNV( GLuint index, GLsizei n, const GLdo
         crPackVertexAttrib2dvARB(index + i, v + 2 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs2fvNV( GLuint index, GLsizei n, const GLfloat *v )
+void PACK_APIENTRY crPackVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -93,7 +93,7 @@ void PACK_APIENTRY crPackVertexAttribs2fvNV( GLuint index, GLsizei n, const GLfl
         crPackVertexAttrib2fvARB(index + i, v + 2 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs2svNV( GLuint index, GLsizei n, const GLshort *v )
+void PACK_APIENTRY crPackVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -101,7 +101,7 @@ void PACK_APIENTRY crPackVertexAttribs2svNV( GLuint index, GLsizei n, const GLsh
         crPackVertexAttrib2svARB(index + i, v + 2 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs3dvNV( GLuint index, GLsizei n, const GLdouble *v )
+void PACK_APIENTRY crPackVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -109,7 +109,7 @@ void PACK_APIENTRY crPackVertexAttribs3dvNV( GLuint index, GLsizei n, const GLdo
         crPackVertexAttrib3dvARB(index + i, v + 3 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs3fvNV( GLuint index, GLsizei n, const GLfloat *v )
+void PACK_APIENTRY crPackVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -117,7 +117,7 @@ void PACK_APIENTRY crPackVertexAttribs3fvNV( GLuint index, GLsizei n, const GLfl
         crPackVertexAttrib3fvARB(index + i, v + 3 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs3svNV( GLuint index, GLsizei n, const GLshort *v )
+void PACK_APIENTRY crPackVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -125,7 +125,7 @@ void PACK_APIENTRY crPackVertexAttribs3svNV( GLuint index, GLsizei n, const GLsh
         crPackVertexAttrib3svARB(index + i, v + 3 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs4dvNV( GLuint index, GLsizei n, const GLdouble *v )
+void PACK_APIENTRY crPackVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -133,7 +133,7 @@ void PACK_APIENTRY crPackVertexAttribs4dvNV( GLuint index, GLsizei n, const GLdo
         crPackVertexAttrib4dvARB(index + i, v + 4 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs4fvNV( GLuint index, GLsizei n, const GLfloat *v )
+void PACK_APIENTRY crPackVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -141,7 +141,7 @@ void PACK_APIENTRY crPackVertexAttribs4fvNV( GLuint index, GLsizei n, const GLfl
         crPackVertexAttrib4fvARB(index + i, v + 4 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs4svNV( GLuint index, GLsizei n, const GLshort *v )
+void PACK_APIENTRY crPackVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -149,7 +149,7 @@ void PACK_APIENTRY crPackVertexAttribs4svNV( GLuint index, GLsizei n, const GLsh
         crPackVertexAttrib4svARB(index + i, v + 4 * i);
 }
 
-void PACK_APIENTRY crPackVertexAttribs4ubvNV( GLuint index, GLsizei n, const GLubyte *v )
+void PACK_APIENTRY crPackVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v)
 {
     GLint i;
     /* reverse order so we hit index 0 last (provoking glVertex) */
@@ -158,7 +158,7 @@ void PACK_APIENTRY crPackVertexAttribs4ubvNV( GLuint index, GLsizei n, const GLu
 }
 
 
-void PACK_APIENTRY crPackExecuteProgramNV( GLenum target, GLuint id, const GLfloat *params )
+void PACK_APIENTRY crPackExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
 {
     const int packet_length = 32;
     unsigned char *data_ptr;
@@ -169,15 +169,15 @@ void PACK_APIENTRY crPackExecuteProgramNV( GLenum target, GLuint id, const GLflo
     WRITE_DATA(4, GLenum, CR_EXECUTEPROGRAMNV_EXTEND_OPCODE);
     WRITE_DATA(8, GLenum, target);
     WRITE_DATA(12, GLuint, id);
-    WRITE_DATA(16, GLfloat, params[0] );
-    WRITE_DATA(20, GLfloat, params[1] );
-    WRITE_DATA(24, GLfloat, params[2] );
-    WRITE_DATA(28, GLfloat, params[3] );
+    WRITE_DATA(16, GLfloat, params[0]);
+    WRITE_DATA(20, GLfloat, params[1]);
+    WRITE_DATA(24, GLfloat, params[2]);
+    WRITE_DATA(28, GLfloat, params[3]);
     WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackLoadProgramNV( GLenum target, GLuint id, GLsizei len, const GLubyte *program )
+void PACK_APIENTRY crPackLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program)
 {
     const int packet_length = 20 + len;
     unsigned char *data_ptr;
@@ -188,13 +188,13 @@ void PACK_APIENTRY crPackLoadProgramNV( GLenum target, GLuint id, GLsizei len, c
     WRITE_DATA(4, GLenum, CR_LOADPROGRAMNV_EXTEND_OPCODE);
     WRITE_DATA(8, GLenum, target);
     WRITE_DATA(12, GLuint, id);
-    WRITE_DATA(16, GLsizei, len );
-    crMemcpy( (void *) (data_ptr + 20), program, len );
+    WRITE_DATA(16, GLsizei, len);
+    crMemcpy((void *) (data_ptr + 20), program, len);
     WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackRequestResidentProgramsNV( GLsizei n, const GLuint *ids )
+void PACK_APIENTRY crPackRequestResidentProgramsNV(GLsizei n, const GLuint *ids)
 {
     CR_GET_PACKER_CONTEXT(pc);
     (void) pc;
@@ -219,7 +219,7 @@ void PACK_APIENTRY crPackProgramNamedParameter4fNV (GLuint id, GLsizei len, cons
     WRITE_DATA(20, GLfloat, y);
     WRITE_DATA(24, GLfloat, z);
     WRITE_DATA(28, GLfloat, w);
-    crMemcpy( (void *) (data_ptr + 32), name, len );
+    crMemcpy((void *) (data_ptr + 32), name, len);
     WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
@@ -239,7 +239,7 @@ void PACK_APIENTRY crPackProgramNamedParameter4dNV (GLuint id, GLsizei len, cons
     WRITE_DOUBLE(24, y);
     WRITE_DOUBLE(32, z);
     WRITE_DOUBLE(40, w);
-    crMemcpy( (void *) (data_ptr + 48), name, len );
+    crMemcpy((void *) (data_ptr + 48), name, len);
 
     WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
@@ -286,44 +286,44 @@ crPackAreProgramsResidentNV(GLsizei n, const GLuint * programs,
 }
 
 
-void PACK_APIENTRY crPackGetProgramNamedParameterfvNV( GLuint id, GLsizei len, const GLubyte *name, GLfloat *params, int *writeback )
+void PACK_APIENTRY crPackGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, GLfloat *params, int *writeback)
 {
     int packet_length = 32 + len;
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, packet_length );
-    WRITE_DATA( 0, GLint, packet_length );
-    WRITE_DATA( 4, GLenum, CR_GETPROGRAMNAMEDPARAMETERFVNV_EXTEND_OPCODE );
-    WRITE_DATA( 8, GLuint, id );
-    WRITE_DATA( 12, GLsizei, len );
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, GLint, packet_length);
+    WRITE_DATA(4, GLenum, CR_GETPROGRAMNAMEDPARAMETERFVNV_EXTEND_OPCODE);
+    WRITE_DATA(8, GLuint, id);
+    WRITE_DATA(12, GLsizei, len);
     crMemcpy(data_ptr + 16, name, len);
-    WRITE_NETWORK_POINTER( 16 + len, (void *) params );
-    WRITE_NETWORK_POINTER( 16 + len + 8, (void *) writeback );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    WRITE_NETWORK_POINTER(16 + len, (void *) params);
+    WRITE_NETWORK_POINTER(16 + len + 8, (void *) writeback);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_CMDBLOCK_CHECK_FLUSH(pc);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackGetProgramNamedParameterdvNV( GLuint id, GLsizei len, const GLubyte *name, GLdouble *params, int *writeback )
+void PACK_APIENTRY crPackGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble *params, int *writeback)
 {
     int packet_length = 32 + len;
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, packet_length );
-    WRITE_DATA( 0, GLint, packet_length );
-    WRITE_DATA( 4, GLenum, CR_GETPROGRAMNAMEDPARAMETERDVNV_EXTEND_OPCODE );
-    WRITE_DATA( 8, GLuint, id );
-    WRITE_DATA( 12, GLsizei, len );
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, GLint, packet_length);
+    WRITE_DATA(4, GLenum, CR_GETPROGRAMNAMEDPARAMETERDVNV_EXTEND_OPCODE);
+    WRITE_DATA(8, GLuint, id);
+    WRITE_DATA(12, GLsizei, len);
     crMemcpy(data_ptr + 16, name, len);
-    WRITE_NETWORK_POINTER( 16 + len, (void *) params );
-    WRITE_NETWORK_POINTER( 16 + len + 8, (void *) writeback );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    WRITE_NETWORK_POINTER(16 + len, (void *) params);
+    WRITE_NETWORK_POINTER(16 + len + 8, (void *) writeback);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_CMDBLOCK_CHECK_FLUSH(pc);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
 
-void PACK_APIENTRY crPackDeleteProgramsARB( GLsizei n, const GLuint *ids )
+void PACK_APIENTRY crPackDeleteProgramsARB(GLsizei n, const GLuint *ids)
 {
     unsigned char *data_ptr;
     int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*ids);
@@ -332,15 +332,15 @@ void PACK_APIENTRY crPackDeleteProgramsARB( GLsizei n, const GLuint *ids )
         return;
 
     data_ptr = (unsigned char *) crPackAlloc(packet_length);
-    WRITE_DATA( 0, GLenum, CR_DELETEPROGRAMSARB_EXTEND_OPCODE );
-    WRITE_DATA( 4, GLsizei, n );
-    crMemcpy( data_ptr + 8, ids, n * sizeof(*ids) );
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
+    WRITE_DATA(0, GLenum, CR_DELETEPROGRAMSARB_EXTEND_OPCODE);
+    WRITE_DATA(4, GLsizei, n);
+    crMemcpy(data_ptr + 8, ids, n * sizeof(*ids));
+    crHugePacket(CR_EXTEND_OPCODE, data_ptr);
+    crPackFree(data_ptr);
 }
 
 
-void PACK_APIENTRY  crPackProgramStringARB( GLenum target, GLenum format, GLsizei len, const void *string )
+void PACK_APIENTRY  crPackProgramStringARB(GLenum target, GLenum format, GLsizei len, const void *string)
 {
     const int packet_length = 20 + len;
     unsigned char *data_ptr;
@@ -351,8 +351,8 @@ void PACK_APIENTRY  crPackProgramStringARB( GLenum target, GLenum format, GLsize
     WRITE_DATA(4, GLenum, CR_PROGRAMSTRINGARB_EXTEND_OPCODE);
     WRITE_DATA(8, GLenum, target);
     WRITE_DATA(12, GLuint, format);
-    WRITE_DATA(16, GLsizei, len );
-    crMemcpy( (void *) (data_ptr + 20), string, len );
+    WRITE_DATA(16, GLsizei, len);
+    crMemcpy((void *) (data_ptr + 20), string, len);
     WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
@@ -363,51 +363,51 @@ void PACK_APIENTRY  crPackProgramStringARB( GLenum target, GLenum format, GLsize
  * non-vector versions.
  */
 
-void PACK_APIENTRY crPackVertexAttrib4NbvARB( GLuint index, const GLbyte *v )
+void PACK_APIENTRY crPackVertexAttrib4NbvARB(GLuint index, const GLbyte *v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 8 );
+    CR_GET_BUFFERED_POINTER(pc, 8);
     pc->current.c.vertexAttrib.b4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLbyte, v[0] );
-    WRITE_DATA( 5, GLbyte, v[1] );
-    WRITE_DATA( 6, GLbyte, v[2] );
-    WRITE_DATA( 7, GLbyte, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4NBVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLbyte, v[0]);
+    WRITE_DATA(5, GLbyte, v[1]);
+    WRITE_DATA(6, GLbyte, v[2]);
+    WRITE_DATA(7, GLbyte, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4NBVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackVertexAttrib4NivARB( GLuint index, const GLint *v )
+void PACK_APIENTRY crPackVertexAttrib4NivARB(GLuint index, const GLint *v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 20 );
+    CR_GET_BUFFERED_POINTER(pc, 20);
     pc->current.c.vertexAttrib.i4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLint, v[0] );
-    WRITE_DATA( 8, GLint, v[1] );
-    WRITE_DATA( 12, GLint, v[2] );
-    WRITE_DATA( 16, GLint, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4NIVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLint, v[0]);
+    WRITE_DATA(8, GLint, v[1]);
+    WRITE_DATA(12, GLint, v[2]);
+    WRITE_DATA(16, GLint, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4NIVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackVertexAttrib4NsvARB( GLuint index, const GLshort *v )
+void PACK_APIENTRY crPackVertexAttrib4NsvARB(GLuint index, const GLshort *v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 12 );
+    CR_GET_BUFFERED_POINTER(pc, 12);
     pc->current.c.vertexAttrib.s4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLshort, v[0] );
-    WRITE_DATA( 6, GLshort, v[1] );
-    WRITE_DATA( 8, GLshort, v[2] );
-    WRITE_DATA( 10, GLshort, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4NSVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLshort, v[0]);
+    WRITE_DATA(6, GLshort, v[1]);
+    WRITE_DATA(8, GLshort, v[2]);
+    WRITE_DATA(10, GLshort, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4NSVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -415,15 +415,15 @@ void PACK_APIENTRY crPackVertexAttrib4NubvARB(GLuint index, const GLubyte * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 8 );
+    CR_GET_BUFFERED_POINTER(pc, 8);
     pc->current.c.vertexAttrib.ub4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLubyte, v[0] );
-    WRITE_DATA( 5, GLubyte, v[1] );
-    WRITE_DATA( 6, GLubyte, v[2] );
-    WRITE_DATA( 7, GLubyte, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4NUBVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLubyte, v[0]);
+    WRITE_DATA(5, GLubyte, v[1]);
+    WRITE_DATA(6, GLubyte, v[2]);
+    WRITE_DATA(7, GLubyte, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4NUBVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -431,15 +431,15 @@ void PACK_APIENTRY crPackVertexAttrib4NuivARB(GLuint index, const GLuint * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 20 );
+    CR_GET_BUFFERED_POINTER(pc, 20);
     pc->current.c.vertexAttrib.ui4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLuint, v[0] );
-    WRITE_DATA( 8, GLuint, v[1] );
-    WRITE_DATA( 12, GLuint, v[2] );
-    WRITE_DATA( 16, GLuint, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4NUIVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLuint, v[0]);
+    WRITE_DATA(8, GLuint, v[1]);
+    WRITE_DATA(12, GLuint, v[2]);
+    WRITE_DATA(16, GLuint, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4NUIVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -447,15 +447,15 @@ void PACK_APIENTRY crPackVertexAttrib4NusvARB(GLuint index, const GLushort * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 12 );
+    CR_GET_BUFFERED_POINTER(pc, 12);
     pc->current.c.vertexAttrib.s4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLushort, v[0] );
-    WRITE_DATA( 6, GLushort, v[1] );
-    WRITE_DATA( 8, GLushort, v[2] );
-    WRITE_DATA( 10, GLushort, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4NUSVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLushort, v[0]);
+    WRITE_DATA(6, GLushort, v[1]);
+    WRITE_DATA(8, GLushort, v[2]);
+    WRITE_DATA(10, GLushort, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4NUSVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -463,15 +463,15 @@ void PACK_APIENTRY crPackVertexAttrib4bvARB(GLuint index, const GLbyte * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 8 );
+    CR_GET_BUFFERED_POINTER(pc, 8);
     pc->current.c.vertexAttrib.b4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLbyte, v[0] );
-    WRITE_DATA( 5, GLbyte, v[1] );
-    WRITE_DATA( 6, GLbyte, v[2] );
-    WRITE_DATA( 7, GLbyte, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4BVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLbyte, v[0]);
+    WRITE_DATA(5, GLbyte, v[1]);
+    WRITE_DATA(6, GLbyte, v[2]);
+    WRITE_DATA(7, GLbyte, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4BVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -479,15 +479,15 @@ void PACK_APIENTRY crPackVertexAttrib4ivARB(GLuint index, const GLint * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 20 );
+    CR_GET_BUFFERED_POINTER(pc, 20);
     pc->current.c.vertexAttrib.i4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLint, v[0] );
-    WRITE_DATA( 8, GLint, v[1] );
-    WRITE_DATA( 12, GLint, v[2] );
-    WRITE_DATA( 16, GLint, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4IVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLint, v[0]);
+    WRITE_DATA(8, GLint, v[1]);
+    WRITE_DATA(12, GLint, v[2]);
+    WRITE_DATA(16, GLint, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4IVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -495,15 +495,15 @@ void PACK_APIENTRY crPackVertexAttrib4uivARB(GLuint index, const GLuint * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 20 );
+    CR_GET_BUFFERED_POINTER(pc, 20);
     pc->current.c.vertexAttrib.ui4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLuint, v[0] );
-    WRITE_DATA( 8, GLuint, v[1] );
-    WRITE_DATA( 12, GLuint, v[2] );
-    WRITE_DATA( 16, GLuint, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4UIVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLuint, v[0]);
+    WRITE_DATA(8, GLuint, v[1]);
+    WRITE_DATA(12, GLuint, v[2]);
+    WRITE_DATA(16, GLuint, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4UIVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -511,15 +511,15 @@ void PACK_APIENTRY crPackVertexAttrib4usvARB(GLuint index, const GLushort * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 12 );
+    CR_GET_BUFFERED_POINTER(pc, 12);
     pc->current.c.vertexAttrib.s4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLushort, v[0] );
-    WRITE_DATA( 6, GLushort, v[1] );
-    WRITE_DATA( 8, GLushort, v[2] );
-    WRITE_DATA( 10, GLushort, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4USVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLushort, v[0]);
+    WRITE_DATA(6, GLushort, v[1]);
+    WRITE_DATA(8, GLushort, v[2]);
+    WRITE_DATA(10, GLushort, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4USVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
@@ -528,15 +528,15 @@ void PACK_APIENTRY crPackVertexAttrib4ubvARB(GLuint index, const GLubyte * v)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
-    CR_GET_BUFFERED_POINTER( pc, 8 );
+    CR_GET_BUFFERED_POINTER(pc, 8);
     pc->current.c.vertexAttrib.ub4[index] = data_ptr + 4;
     pc->current.attribsUsedMask |= (1 << index);
-    WRITE_DATA( 0, GLuint, index );
-    WRITE_DATA( 4, GLubyte, v[0] );
-    WRITE_DATA( 5, GLubyte, v[1] );
-    WRITE_DATA( 6, GLubyte, v[2] );
-    WRITE_DATA( 7, GLubyte, v[3] );
-    WRITE_OPCODE( pc, CR_VERTEXATTRIB4UBVARB_OPCODE );
+    WRITE_DATA(0, GLuint, index);
+    WRITE_DATA(4, GLubyte, v[0]);
+    WRITE_DATA(5, GLubyte, v[1]);
+    WRITE_DATA(6, GLubyte, v[2]);
+    WRITE_DATA(7, GLubyte, v[3]);
+    WRITE_OPCODE(pc, CR_VERTEXATTRIB4UBVARB_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c b/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c
index 4e7cec5..ddfff76 100644
--- a/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c
@@ -7,76 +7,76 @@
 #include "packer.h"
 #include "cr_opcodes.h"
 
-static GLboolean __handleCombinerParameterData( GLenum pname, const GLfloat *params, GLenum extended_opcode )
+static GLboolean __handleCombinerParameterData(GLenum pname, const GLfloat *params, GLenum extended_opcode)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned int params_length = 0;
-    unsigned int packet_length = sizeof( int ) + sizeof( extended_opcode ) + sizeof( pname );
+    unsigned int packet_length = sizeof(int) + sizeof(extended_opcode) + sizeof(pname);
     unsigned char *data_ptr;
 
-    switch( pname )
+    switch(pname)
     {
         case GL_CONSTANT_COLOR0_NV:
         case GL_CONSTANT_COLOR1_NV:
-            params_length = 4 * sizeof( *params );
+            params_length = 4 * sizeof(*params);
             break;
         case GL_NUM_GENERAL_COMBINERS_NV:
         case GL_COLOR_SUM_CLAMP_NV:
-            params_length = sizeof( *params );
+            params_length = sizeof(*params);
             break;
         default:
-            __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                     "crPackCombinerParameter(bad pname)" );
+            __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                     "crPackCombinerParameter(bad pname)");
             CRASSERT(0);
             return GL_FALSE;
     }
     packet_length += params_length;
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, int, packet_length );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, extended_opcode );
-    WRITE_DATA( sizeof( int ) + 4, GLenum, pname );
-    WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] );
-    if (params_length > sizeof( *params ))
+    CR_GET_BUFFERED_POINTER(pc, packet_length);
+    WRITE_DATA(0, int, packet_length);
+    WRITE_DATA(sizeof(int) + 0, GLenum, extended_opcode);
+    WRITE_DATA(sizeof(int) + 4, GLenum, pname);
+    WRITE_DATA(sizeof(int) + 8, GLfloat, params[0]);
+    if (params_length > sizeof(*params))
     {
-        WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] );
-        WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] );
-        WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] );
+        WRITE_DATA(sizeof(int) + 12, GLfloat, params[1]);
+        WRITE_DATA(sizeof(int) + 16, GLfloat, params[2]);
+        WRITE_DATA(sizeof(int) + 20, GLfloat, params[3]);
         CRASSERT(packet_length == sizeof(int) + 20 + 4);
     }
     return GL_TRUE;
 }
 
-void PACK_APIENTRY crPackCombinerParameterfvNV( GLenum pname, const GLfloat *params )
+void PACK_APIENTRY crPackCombinerParameterfvNV(GLenum pname, const GLfloat *params)
 {
     CR_GET_PACKER_CONTEXT(pc);
-    if (__handleCombinerParameterData( pname, params, CR_COMBINERPARAMETERFVNV_EXTEND_OPCODE ))
-        WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    if (__handleCombinerParameterData(pname, params, CR_COMBINERPARAMETERFVNV_EXTEND_OPCODE))
+        WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackCombinerParameterivNV( GLenum pname, const GLint *params )
+void PACK_APIENTRY crPackCombinerParameterivNV(GLenum pname, const GLint *params)
 {
     /* floats and ints are the same size, so the packing should be the same */
     CR_GET_PACKER_CONTEXT(pc);
-    if (__handleCombinerParameterData( pname, (const GLfloat *) params, CR_COMBINERPARAMETERIVNV_EXTEND_OPCODE ))
-        WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    if (__handleCombinerParameterData(pname, (const GLfloat *) params, CR_COMBINERPARAMETERIVNV_EXTEND_OPCODE))
+        WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
 
-void PACK_APIENTRY crPackCombinerStageParameterfvNV( GLenum stage, GLenum pname, const GLfloat *params )
+void PACK_APIENTRY crPackCombinerStageParameterfvNV(GLenum stage, GLenum pname, const GLfloat *params)
 {
     CR_GET_PACKER_CONTEXT(pc);
     unsigned char *data_ptr;
 
-    CR_GET_BUFFERED_POINTER(pc, 32 );
-    WRITE_DATA( 0, GLint, 32 );
-    WRITE_DATA( 4, GLenum, CR_COMBINERSTAGEPARAMETERFVNV_EXTEND_OPCODE );
-    WRITE_DATA( 8, GLenum, stage );
-    WRITE_DATA( 12, GLenum, pname );
-    WRITE_DATA( 16, GLfloat, params[0] );
-    WRITE_DATA( 20, GLfloat, params[1] );
-    WRITE_DATA( 24, GLfloat, params[2] );
-    WRITE_DATA( 28, GLfloat, params[3] );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
+    CR_GET_BUFFERED_POINTER(pc, 32);
+    WRITE_DATA(0, GLint, 32);
+    WRITE_DATA(4, GLenum, CR_COMBINERSTAGEPARAMETERFVNV_EXTEND_OPCODE);
+    WRITE_DATA(8, GLenum, stage);
+    WRITE_DATA(12, GLenum, pname);
+    WRITE_DATA(16, GLfloat, params[0]);
+    WRITE_DATA(20, GLfloat, params[1]);
+    WRITE_DATA(24, GLfloat, params[2]);
+    WRITE_DATA(28, GLfloat, params[3]);
+    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
     CR_UNLOCK_PACKER_CONTEXT(pc);
 }
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap.py b/src/VBox/GuestHost/OpenGL/packer/pack_swap.py
old mode 100644
new mode 100755
index aaca544..763f04e
--- a/src/VBox/GuestHost/OpenGL/packer/pack_swap.py
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys, string
 
 sys.path.append( "../glapi_parser" )
@@ -15,12 +16,12 @@ if len(sys.argv) != 2:
 
 file = open(sys.argv[1])
 
-print "/* THIS FILE IS AUTOGENERATED FROM %s BY pack_swap.py */\n\n" % sys.argv[1]
+print("/* THIS FILE IS AUTOGENERATED FROM %s BY pack_swap.py */\n\n" % sys.argv[1])
 
 for line in file.readlines():
     line = line.rstrip()
     if line.find( "crPackAlloc" ) != -1 or line.find( "crPackFree" ) != -1:
-        print line
+        print(line)
         continue
     elif line.find( "crPack" ) != -1:
         fun_index = line.find( "crPack" )
@@ -34,40 +35,40 @@ for line in file.readlines():
         if quote_index == -1:
             quote_index = 1000000; # HACK HACK
         the_index = min( min( paren_index, space_index ), quote_index )
-        print "%sSWAP%s" % (line[:the_index], line[the_index:])
+        print("%sSWAP%s" % (line[:the_index], line[the_index:]))
     elif line.find("WRITE_DATA_AI") != -1:
         lparen_index = line.find( "(" )
         rparen_index = line.rfind( ")" )
-        args = map( string.strip, line[lparen_index+1:rparen_index].split( "," ) )
+        args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) ))
         indentation = line[:line.find( "WRITE_DATA_AI" )]
         if apiutil.sizeof(args[0]) == 1:
-            print "%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1])
+            print("%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1]))
         elif apiutil.sizeof(args[0]) == 2:
-            print "%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1])
+            print("%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1]))
         elif args[0] == 'GLfloat' or args[0] == 'GLclampf':
-            print "%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0])
+            print("%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0]))
         elif apiutil.sizeof(args[0]) == 4:
-            print "%sWRITE_DATA_AI(%s, SWAP32(%s) );" % (indentation, args[0], args[1])
+            print("%sWRITE_DATA_AI(%s, SWAP32(%s));" % (indentation, args[0], args[1]))
         else:
             print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
             sys.exit(-1)
     elif line.find( "WRITE_DATA" ) != -1:
         lparen_index = line.find( "(" )
         rparen_index = line.rfind( ")" )
-        args = map( string.strip, line[lparen_index+1:rparen_index].split( "," ) )
+        args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) ))
         indentation = line[:line.find( "WRITE_DATA" )]
         if apiutil.sizeof(args[1]) == 1:
-            print "%sWRITE_DATA( %s, %s, %s );" % (indentation, args[0], args[1], args[2])
+            print("%sWRITE_DATA(%s, %s, %s);" % (indentation, args[0], args[1], args[2]))
         elif apiutil.sizeof(args[1]) == 2:
-            print "%sWRITE_DATA( %s, %s, SWAP16(%s) );" % (indentation, args[0], args[1], args[2])
+            print("%sWRITE_DATA(%s, %s, SWAP16(%s));" % (indentation, args[0], args[1], args[2]))
         elif args[1] == 'GLfloat' or args[1] == 'GLclampf':
-            print "%sWRITE_DATA( %s, GLuint, SWAPFLOAT(%s) );" % (indentation, args[0], args[2])
+            print("%sWRITE_DATA(%s, GLuint, SWAPFLOAT(%s));" % (indentation, args[0], args[2]))
         elif apiutil.sizeof(args[1]) == 4:
-            print "%sWRITE_DATA( %s, %s, SWAP32(%s) );" % (indentation, args[0], args[1], args[2])
+            print("%sWRITE_DATA(%s, %s, SWAP32(%s));" % (indentation, args[0], args[1], args[2]))
         else:
             print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
             sys.exit(-1)
     elif line.find( "WRITE_DOUBLE" ) != -1:
-        print line.replace( "WRITE_DOUBLE", "WRITE_SWAPPED_DOUBLE" )
+        print(line.replace( "WRITE_DOUBLE", "WRITE_SWAPPED_DOUBLE" ))
     else:
-        print line
+        print(line)
diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c b/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c
index 5700245..241f899 100644
--- a/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c
+++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c
@@ -13,9 +13,9 @@
  * and are computed into the packet instead of copied.
  */
 
-static int __gl_Map2NumComponents( GLenum target )
+static int __gl_Map2NumComponents(GLenum target)
 {
-    switch( target )
+    switch(target)
     {
     case GL_MAP2_VERTEX_3:
     case GL_MAP2_NORMAL:
@@ -35,9 +35,9 @@ static int __gl_Map2NumComponents( GLenum target )
     }
 }
 
-static int __gl_Map1NumComponents( GLenum target )
+static int __gl_Map1NumComponents(GLenum target)
 {
-    switch( target )
+    switch(target)
     {
     case GL_MAP1_VERTEX_3:
     case GL_MAP1_NORMAL:
@@ -66,37 +66,37 @@ void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1,
     int comp;
     GLdouble *dest_data, *src_data;
     int packet_length = 
-        sizeof( target ) + 
-        sizeof( u1 ) +
-        sizeof( u2 ) +
-        sizeof( uorder ) +
-        sizeof( ustride ) +
-        sizeof( v1 ) +
-        sizeof( v2 ) + 
-        sizeof( vorder ) +
-        sizeof( vstride );
-
-    int num_components = __gl_Map2NumComponents( target );
+        sizeof(target) + 
+        sizeof(u1) +
+        sizeof(u2) +
+        sizeof(uorder) +
+        sizeof(ustride) +
+        sizeof(v1) +
+        sizeof(v2) + 
+        sizeof(vorder) +
+        sizeof(vstride);
+
+    int num_components = __gl_Map2NumComponents(target);
     if (num_components < 0)
     {
-        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap2d(bad target)" );
+        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                 "crPackMap2d(bad target)");
         return;
     }
 
-    packet_length += num_components*uorder*vorder*sizeof( *points );
+    packet_length += num_components*uorder*vorder*sizeof(*points);
 
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
+    data_ptr = (unsigned char *) crPackAlloc(packet_length);
 
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_SWAPPED_DOUBLE( 4, u1 );
-    WRITE_SWAPPED_DOUBLE( 12, u2 );
-    WRITE_DATA( 20, GLint, SWAP32(num_components) );
-    WRITE_DATA( 24, GLint, SWAP32(uorder) );
-    WRITE_SWAPPED_DOUBLE( 28, v1 );
-    WRITE_SWAPPED_DOUBLE( 36, v2 );
-    WRITE_DATA( 44, GLint, SWAP32(num_components*uorder) );
-    WRITE_DATA( 48, GLint, SWAP32(vorder) );
+    WRITE_DATA(0, GLenum, SWAP32(target));
+    WRITE_SWAPPED_DOUBLE(4, u1);
+    WRITE_SWAPPED_DOUBLE(12, u2);
+    WRITE_DATA(20, GLint, SWAP32(num_components));
+    WRITE_DATA(24, GLint, SWAP32(uorder));
+    WRITE_SWAPPED_DOUBLE(28, v1);
+    WRITE_SWAPPED_DOUBLE(36, v2);
+    WRITE_DATA(44, GLint, SWAP32(num_components*uorder));
+    WRITE_DATA(48, GLint, SWAP32(vorder));
 
     dest_data = (GLdouble *) (data_ptr + 52);
     src_data = (GLdouble *) points;
@@ -106,7 +106,7 @@ void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1,
         {
             for (comp = 0 ; comp < num_components ; comp++)
             {
-                WRITE_SWAPPED_DOUBLE( ((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp) );
+                WRITE_SWAPPED_DOUBLE(((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp));
             }
             dest_data += num_components;
             src_data += ustride;
@@ -114,8 +114,8 @@ void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1,
         src_data += vstride - ustride*uorder;
     }
 
-    crHugePacket( CR_MAP2D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
+    crHugePacket(CR_MAP2D_OPCODE, data_ptr);
+    crPackFree(data_ptr);
 }
 
 void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1, 
@@ -127,37 +127,37 @@ void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1,
     int comp;
     GLfloat *dest_data, *src_data;
     int packet_length = 
-        sizeof( target ) + 
-        sizeof( u1 ) +
-        sizeof( u2 ) +
-        sizeof( uorder ) +
-        sizeof( ustride ) +
-        sizeof( v1 ) +
-        sizeof( v2 ) + 
-        sizeof( vorder ) +
-        sizeof( vstride );
-
-    int num_components = __gl_Map2NumComponents( target );
+        sizeof(target) + 
+        sizeof(u1) +
+        sizeof(u2) +
+        sizeof(uorder) +
+        sizeof(ustride) +
+        sizeof(v1) +
+        sizeof(v2) + 
+        sizeof(vorder) +
+        sizeof(vstride);
+
+    int num_components = __gl_Map2NumComponents(target);
     if (num_components < 0)
     {
-        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap2f(bad target)" );
+        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                 "crPackMap2f(bad target)");
         return;
     }
 
-    packet_length += num_components*uorder*vorder*sizeof( *points );
+    packet_length += num_components*uorder*vorder*sizeof(*points);
 
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
+    data_ptr = (unsigned char *) crPackAlloc(packet_length);
 
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_DATA( 4, GLuint, SWAPFLOAT(u1) );
-    WRITE_DATA( 8, GLuint, SWAPFLOAT(u2) );
-    WRITE_DATA( 12, GLint, SWAP32(num_components) );
-    WRITE_DATA( 16, GLint, SWAP32(uorder) );
-    WRITE_DATA( 20, GLuint, SWAPFLOAT(v1) );
-    WRITE_DATA( 24, GLuint, SWAPFLOAT(v2) );
-    WRITE_DATA( 28, GLint, SWAP32(num_components*uorder) );
-    WRITE_DATA( 32, GLint, SWAP32(vorder) );
+    WRITE_DATA(0, GLenum, SWAP32(target));
+    WRITE_DATA(4, GLuint, SWAPFLOAT(u1));
+    WRITE_DATA(8, GLuint, SWAPFLOAT(u2));
+    WRITE_DATA(12, GLint, SWAP32(num_components));
+    WRITE_DATA(16, GLint, SWAP32(uorder));
+    WRITE_DATA(20, GLuint, SWAPFLOAT(v1));
+    WRITE_DATA(24, GLuint, SWAPFLOAT(v2));
+    WRITE_DATA(28, GLint, SWAP32(num_components*uorder));
+    WRITE_DATA(32, GLint, SWAP32(vorder));
 
     dest_data = (GLfloat *) (data_ptr + 36);
     src_data = (GLfloat *) points;
@@ -167,7 +167,7 @@ void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1,
         {
             for (comp = 0 ; comp < num_components ; comp++)
             {
-                WRITE_DATA( (unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT( *(src_data + comp) ) );
+                WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp)));
             }
             dest_data += num_components;
             src_data += ustride;
@@ -175,42 +175,42 @@ void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1,
         src_data += vstride - ustride*uorder;
     }
 
-    crHugePacket( CR_MAP2F_OPCODE, data_ptr );
-    crPackFree( data_ptr );
+    crHugePacket(CR_MAP2F_OPCODE, data_ptr);
+    crPackFree(data_ptr);
 }
 
-void PACK_APIENTRY crPackMap1dSWAP( GLenum target, GLdouble u1,
-        GLdouble u2, GLint stride, GLint order, const GLdouble *points )
+void PACK_APIENTRY crPackMap1dSWAP(GLenum target, GLdouble u1,
+        GLdouble u2, GLint stride, GLint order, const GLdouble *points)
 {
     unsigned char *data_ptr;
     int packet_length = 
-        sizeof( target ) + 
-        sizeof( u1 ) +
-        sizeof( u2 ) + 
-        sizeof( stride ) + 
-        sizeof( order );
+        sizeof(target) + 
+        sizeof(u1) +
+        sizeof(u2) + 
+        sizeof(stride) + 
+        sizeof(order);
 
-    int num_components = __gl_Map1NumComponents( target );
+    int num_components = __gl_Map1NumComponents(target);
     GLdouble *src_data, *dest_data;
     int u;
     int comp;
 
     if (num_components < 0)
     {
-        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap1d(bad target)" );
+        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                 "crPackMap1d(bad target)");
         return;
     }
 
-    packet_length += num_components * order * sizeof( *points );
+    packet_length += num_components * order * sizeof(*points);
 
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
+    data_ptr = (unsigned char *) crPackAlloc(packet_length);
 
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_SWAPPED_DOUBLE( 4, u1 );
-    WRITE_SWAPPED_DOUBLE( 12, u2 );
-    WRITE_DATA( 20, GLint, SWAP32(num_components) );
-    WRITE_DATA( 24, GLint, SWAP32(order) );
+    WRITE_DATA(0, GLenum, SWAP32(target));
+    WRITE_SWAPPED_DOUBLE(4, u1);
+    WRITE_SWAPPED_DOUBLE(12, u2);
+    WRITE_DATA(20, GLint, SWAP32(num_components));
+    WRITE_DATA(24, GLint, SWAP32(order));
 
     dest_data = (GLdouble *) (data_ptr + 28);
     src_data = (GLdouble *) points;
@@ -218,48 +218,48 @@ void PACK_APIENTRY crPackMap1dSWAP( GLenum target, GLdouble u1,
     {
         for (comp = 0 ; comp < num_components ; comp++)
         {
-            WRITE_SWAPPED_DOUBLE( (unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, *(src_data + comp) );
+            WRITE_SWAPPED_DOUBLE((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, *(src_data + comp));
         }
         dest_data += num_components;
         src_data += stride;
     }
 
-    crHugePacket( CR_MAP1D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
+    crHugePacket(CR_MAP1D_OPCODE, data_ptr);
+    crPackFree(data_ptr);
 }
 
-void PACK_APIENTRY crPackMap1fSWAP( GLenum target, GLfloat u1,
-        GLfloat u2, GLint stride, GLint order, const GLfloat *points )
+void PACK_APIENTRY crPackMap1fSWAP(GLenum target, GLfloat u1,
+        GLfloat u2, GLint stride, GLint order, const GLfloat *points)
 {
     unsigned char *data_ptr;
     int packet_length = 
-        sizeof( target ) + 
-        sizeof( u1 ) +
-        sizeof( u2 ) + 
-        sizeof( stride ) + 
-        sizeof( order );
+        sizeof(target) + 
+        sizeof(u1) +
+        sizeof(u2) + 
+        sizeof(stride) + 
+        sizeof(order);
 
-    int num_components = __gl_Map1NumComponents( target );
+    int num_components = __gl_Map1NumComponents(target);
     GLfloat *src_data, *dest_data;
     int u;
     int comp;
 
     if (num_components < 0)
     {
-        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap1f(bad target)" );
+        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
+                                 "crPackMap1f(bad target)");
         return;
     }
 
-    packet_length += num_components * order * sizeof( *points );
+    packet_length += num_components * order * sizeof(*points);
 
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
+    data_ptr = (unsigned char *) crPackAlloc(packet_length);
 
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_DATA( 4, GLuint, SWAPFLOAT(u1) );
-    WRITE_DATA( 8, GLuint, SWAPFLOAT(u2) );
-    WRITE_DATA( 12, GLint, SWAP32(num_components) );
-    WRITE_DATA( 16, GLint, SWAP32(order) );
+    WRITE_DATA(0, GLenum, SWAP32(target));
+    WRITE_DATA(4, GLuint, SWAPFLOAT(u1));
+    WRITE_DATA(8, GLuint, SWAPFLOAT(u2));
+    WRITE_DATA(12, GLint, SWAP32(num_components));
+    WRITE_DATA(16, GLint, SWAP32(order));
 
     dest_data = (GLfloat *) (data_ptr + 20);
     src_data = (GLfloat *) points;
@@ -267,12 +267,12 @@ void PACK_APIENTRY crPackMap1fSWAP( GLenum target, GLfloat u1,
     {
         for (comp = 0 ; comp < num_components ; comp++)
         {
-            WRITE_DATA( (unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT( *(src_data + comp) ) );
+            WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp)));
         }
         dest_data += num_components;
         src_data += stride;
     }
 
-    crHugePacket( CR_MAP1F_OPCODE, data_ptr );
-    crPackFree( data_ptr );
+    crHugePacket(CR_MAP1F_OPCODE, data_ptr);
+    crPackFree(data_ptr);
 }
diff --git a/src/VBox/GuestHost/OpenGL/packer/packer.py b/src/VBox/GuestHost/OpenGL/packer/packer.py
index 647a0b4..9e97920 100755
--- a/src/VBox/GuestHost/OpenGL/packer/packer.py
+++ b/src/VBox/GuestHost/OpenGL/packer/packer.py
@@ -5,6 +5,7 @@
 
 # This script generates the packer.c file from the gl_header.parsed file.
 
+from __future__ import print_function
 import sys, string, re
 
 import apiutil
@@ -15,24 +16,24 @@ def WriteData( offset, arg_type, arg_name, is_swapped ):
     """Return a string to write a variable to the packing buffer."""
     retval = 9
     if apiutil.IsPointer(arg_type):
-        retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name )
+        retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name )
     else:   
         if is_swapped:
             if arg_type == "GLfloat" or arg_type == "GLclampf":
-                retval = "\tWRITE_DATA( %d, GLuint, SWAPFLOAT(%s) );" % (offset, arg_name)
+                retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % (offset, arg_name)
             elif arg_type == "GLdouble" or arg_type == "GLclampd":
-                retval = "\tWRITE_SWAPPED_DOUBLE( %d, %s );" % (offset, arg_name)
+                retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name)
             elif apiutil.sizeof(arg_type) == 1:
-                retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
+                retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
             elif apiutil.sizeof(arg_type) == 2:
-                retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % (offset, arg_type, arg_name)
+                retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % (offset, arg_type, arg_name)
             elif apiutil.sizeof(arg_type) == 4:
-                retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % (offset, arg_type, arg_name)
+                retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % (offset, arg_type, arg_name)
         else:
             if arg_type == "GLdouble" or arg_type == "GLclampd":
-                retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name)
+                retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
             else:
-                retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
+                retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
     if retval == 9:
         print >>sys.stderr, "no retval for %s %s" % (arg_name, arg_type)
         assert 0
@@ -45,7 +46,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = '%s%s' % (k[:1].lower(),k[1:])
         type = m.group(3) + m.group(2)
-        print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
+        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
         return
 
     m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)EXT$", func_name )
@@ -53,7 +54,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = 'secondaryColor'
         type = m.group(3) + m.group(2)
-        print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
+        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
         return
 
     m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
@@ -61,7 +62,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = 'texCoord'
         type = m.group(3) + m.group(2)
-        print "\tpc->current.c.%s.%s[0] = data_ptr;" % (name,type)
+        print("\tpc->current.c.%s.%s[0] = data_ptr;" % (name,type))
         return
 
     m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name )
@@ -69,7 +70,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = 'texCoord'
         type = m.group(3) + m.group(2)
-        print "\tpc->current.c.%s.%s[texture-GL_TEXTURE0_ARB] = data_ptr + 4;" % (name,type)
+        print("\tpc->current.c.%s.%s[texture-GL_TEXTURE0_ARB] = data_ptr + 4;" % (name,type))
         return
 
     m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name )
@@ -77,7 +78,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = 'index'
         type = m.group(2) + "1"
-        print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
+        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
         return
 
     m = re.match( r"^(EdgeFlag)$", func_name )
@@ -85,7 +86,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = 'edgeFlag'
         type = "l1"
-        print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
+        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
         return
 
     m = re.match( r"^(FogCoord)(f|d)EXT$", func_name )
@@ -93,7 +94,7 @@ def UpdateCurrentPointer( func_name ):
         k = m.group(1)
         name = 'fogCoord'
         type = m.group(2) + "1"
-        print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
+        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
         return
 
 
@@ -103,10 +104,10 @@ def UpdateCurrentPointer( func_name ):
         name = 'vertexAttrib'
         type = m.group(3) + m.group(2)
         # Add 12 to skip the packet length, opcode and index fields
-        print "\tpc->current.c.%s.%s[index] = data_ptr + 4;" % (name,type)
+        print("\tpc->current.c.%s.%s[index] = data_ptr + 4;" % (name,type))
         if m.group(4) == "ARB" or m.group(4) == "NV":
-            print "\tpc->current.attribsUsedMask |= (1 << index);"
-            print "\tpc->current.changedVertexAttrib |= (1 << index);"
+            print("\tpc->current.attribsUsedMask |= (1 << index);")
+            print("\tpc->current.changedVertexAttrib |= (1 << index);")
         return
 
 
@@ -114,11 +115,11 @@ def UpdateCurrentPointer( func_name ):
 def PrintFunc( func_name, params, is_swapped, can_have_pointers ):
     """Emit a packer function."""
     if is_swapped:
-        print 'void PACK_APIENTRY crPack%sSWAP( %s )' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params))
+        print('void PACK_APIENTRY crPack%sSWAP(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
     else:
-        print 'void PACK_APIENTRY crPack%s( %s )' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params))
-    print '{'
-    print '\tCR_GET_PACKER_CONTEXT(pc);'
+        print('void PACK_APIENTRY crPack%s(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
+    print('{')
+    print('\tCR_GET_PACKER_CONTEXT(pc);')
 
     # Save original function name
     orig_func_name = func_name
@@ -137,10 +138,10 @@ def PrintFunc( func_name, params, is_swapped, can_have_pointers ):
             bail_out = 1
     if bail_out:
         for (name, type, vecSize) in nonVecParams:
-            print '\t(void)%s;' % (name)
-        print '\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers)
-        print '\t(void) pc;'
-        print '}'
+            print('\t(void)%s;' % (name))
+        print('\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers))
+        print('\t(void) pc;')
+        print('}')
         # XXX we should really abort here
         return
 
@@ -150,40 +151,40 @@ def PrintFunc( func_name, params, is_swapped, can_have_pointers ):
         is_extended = 0
 
 
-    print "\tunsigned char *data_ptr;"
-    print '\t(void) pc;'
+    print("\tunsigned char *data_ptr;")
+    print('\t(void) pc;')
     #if func_name == "Enable" or func_name == "Disable":
     #   print "\tCRASSERT(!pc->buffer.geometry_only); /* sanity check */"
 
     for index in range(0,len(params)):
         (name, type, vecSize) = params[index]
         if vecSize>0 and func_name!=orig_func_name:
-            print "    if (!%s) {" % name
+            print("    if (!%s) {" % name)
             # Know the reason for this one, so avoid the spam.
             if orig_func_name != "SecondaryColor3fvEXT":
-                print "        crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name)
-            print "        return;"
-            print "    }"
+                print("        crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name))
+            print("        return;")
+            print("    }")
 
     packet_length = apiutil.PacketLength(nonVecParams)
 
     if packet_length == 0 and not is_extended:
-        print "\tCR_GET_BUFFERED_POINTER_NO_ARGS( pc );"
+        print("\tCR_GET_BUFFERED_POINTER_NO_ARGS(pc);")
     elif func_name[:9] == "Translate" or func_name[:5] == "Color":
         # XXX WTF is the purpose of this?
         if is_extended:
             packet_length += 8
-        print "\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, %d, GL_TRUE );" % packet_length
+        print("\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, %d, GL_TRUE);" % packet_length)
     else:
         if is_extended:
             packet_length += 8
-        print "\tCR_GET_BUFFERED_POINTER( pc, %d );" % packet_length
+        print("\tCR_GET_BUFFERED_POINTER(pc, %d);" % packet_length)
     UpdateCurrentPointer( func_name )
 
     if is_extended:
         counter = 8
-        print WriteData( 0, 'GLint', packet_length, is_swapped )
-        print WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped )
+        print(WriteData( 0, 'GLint', packet_length, is_swapped ))
+        print(WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped ))
     else:
         counter = 0
 
@@ -194,11 +195,11 @@ def PrintFunc( func_name, params, is_swapped, can_have_pointers ):
         if vecSize > 0 and func_name != orig_func_name:
             ptrType = apiutil.PointerType(type)
             for i in range(0, vecSize):
-                print WriteData( counter + i * apiutil.sizeof(ptrType),
-                                 ptrType, "%s[%d]" % (name, i), is_swapped )
+                print(WriteData( counter + i * apiutil.sizeof(ptrType),
+                                 ptrType, "%s[%d]" % (name, i), is_swapped ))
             # XXX increment counter here?
         else:
-            print WriteData( counter, type, name, is_swapped )
+            print(WriteData( counter, type, name, is_swapped ))
             if apiutil.IsPointer(type):
                 counter += apiutil.PointerSize()
             else:
@@ -206,15 +207,15 @@ def PrintFunc( func_name, params, is_swapped, can_have_pointers ):
 
     # finish up
     if is_extended:
-        print "\tWRITE_OPCODE( pc, CR_EXTEND_OPCODE );"
+        print("\tWRITE_OPCODE(pc, CR_EXTEND_OPCODE);")
     else:
-        print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name )
+        print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name ))
 
     if "get" in apiutil.Properties(func_name):
-        print '\tCR_CMDBLOCK_CHECK_FLUSH(pc);'
+        print('\tCR_CMDBLOCK_CHECK_FLUSH(pc);')
 
-    print '\tCR_UNLOCK_PACKER_CONTEXT(pc);'
-    print '}\n'
+    print('\tCR_UNLOCK_PACKER_CONTEXT(pc);')
+    print('}\n')
 
 
 r0_funcs = [ 'ChromiumParameteriCR', 'WindowSize', 'WindowShow', 'WindowPosition' ]
@@ -222,7 +223,7 @@ r0_funcs = [ 'ChromiumParameteriCR', 'WindowSize', 'WindowShow', 'WindowPosition
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE packer.py SCRIPT */
 
 /* For each of the OpenGL functions we have a packer function which
@@ -232,7 +233,7 @@ print """
 #include "packer.h"
 #include "cr_opcodes.h"
 
-"""
+""")
 
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
@@ -251,7 +252,7 @@ for func_name in keys:
 
     if return_type != 'void':
         # Yet another gross hack for glGetString
-        if string.find( return_type, '*' ) == -1:
+        if return_type.find('*') == -1:
             return_type = return_type + " *"
         params.append(("return_value", return_type, 0))
 
@@ -263,11 +264,11 @@ for func_name in keys:
         pointers_ok = 1
 
     if not func_name in r0_funcs:
-        print '#ifndef IN_RING0'
+        print('#ifndef IN_RING0')
         
     PrintFunc( func_name, params, 0, pointers_ok )
     PrintFunc( func_name, params, 1, pointers_ok )
     
     if not func_name in r0_funcs:
-        print '#endif'
+        print('#endif')
     
diff --git a/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py b/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py
old mode 100644
new mode 100755
index 992880b..355962d
--- a/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py
+++ b/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py
@@ -5,8 +5,8 @@
 
 # This script generates the packer_bbox.c file from gl_header.parsed
 
+from __future__ import print_function
 import sys
-import cPickle
 import string
 
 import apiutil
@@ -14,7 +14,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE packer_bbox.py SCRIPT */
 
 /* These functions pack glVertex functions and also update the bounding box
@@ -30,7 +30,7 @@ print """
 /**
  * Reset packer bounding box to empty state.
  */
-void crPackResetBoundingBox( CRPackContext *pc )
+void crPackResetBoundingBox(CRPackContext *pc)
 {
 	pc->bounds_min.x =  FLT_MAX;
 	pc->bounds_min.y =  FLT_MAX;
@@ -45,9 +45,9 @@ void crPackResetBoundingBox( CRPackContext *pc )
  * Query current bounding box.
  * \return GL_TRUE if non-empty box, GL_FALSE if empty box.
  */
-GLboolean crPackGetBoundingBox( CRPackContext *pc,
-                                GLfloat *xmin, GLfloat *ymin, GLfloat *zmin,
-                                GLfloat *xmax, GLfloat *ymax, GLfloat *zmax)
+GLboolean crPackGetBoundingBox(CRPackContext *pc,
+                               GLfloat *xmin, GLfloat *ymin, GLfloat *zmin,
+                               GLfloat *xmax, GLfloat *ymax, GLfloat *zmax)
 {
 	if (pc->bounds_min.x != FLT_MAX) {
 		*xmin = pc->bounds_min.x;
@@ -63,28 +63,28 @@ GLboolean crPackGetBoundingBox( CRPackContext *pc,
 	}
 }
 
-"""
+""")
 
 def WriteData( offset, arg_type, arg_name, is_swapped ):
-	if string.find( arg_type, '*' ) != -1:
-		retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name )
+	if arg_type.find('*') != -1:
+		retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name )
 	else:	
 		if is_swapped:
 			if arg_type == "GLfloat" or arg_type == "GLclampf":
-				retval = "\tWRITE_DATA( %d, GLuint, SWAPFLOAT(%s) );" % (offset, arg_name)
+				retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % (offset, arg_name)
 			elif arg_type == "GLdouble" or arg_type == "GLclampd":
-				retval = "\tWRITE_SWAPPED_DOUBLE( %d, %s );" % (offset, arg_name)
+				retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name)
 			elif apiutil.sizeof(arg_type) == 1:
-				retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
+				retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
 			elif apiutil.sizeof(arg_type) == 2:
-				retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % (offset, arg_type, arg_name)
+				retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % (offset, arg_type, arg_name)
 			elif apiutil.sizeof(arg_type) == 4:
-				retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % (offset, arg_type, arg_name)
+				retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % (offset, arg_type, arg_name)
 		else:
 			if arg_type == "GLdouble" or arg_type == "GLclampd":
-				retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name)
+				retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
 			else:
-				retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
+				retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
 	return retval
 
 
@@ -134,7 +134,7 @@ def PrintFunction( func_name, extSuffix, num_coords, argtype,
 	elif argtype == "d":
 		vector_type = "GLdouble"
 	else:
-		print "type is %s" % argtype
+		print("type is %s" % argtype)
 		abort()
 
 	if do_vector:
@@ -145,9 +145,9 @@ def PrintFunction( func_name, extSuffix, num_coords, argtype,
 
 	params = apiutil.Parameters(func_name + extSuffix)
 
-	print 'void PACK_APIENTRY crPack%sBBOX%s%s( %s )' % (func_name + extSuffix, countSuffix,
-			 swapSuffix, apiutil.MakeDeclarationString(params))
-	print '{'
+	print('void PACK_APIENTRY crPack%sBBOX%s%s(%s)' % (func_name + extSuffix, countSuffix,
+			 swapSuffix, apiutil.MakeDeclarationString(params)))
+	print('{')
 
 	if do_vector:
 		# vector version
@@ -166,8 +166,8 @@ def PrintFunction( func_name, extSuffix, num_coords, argtype,
 			packet_length += 2
 
 
-	print "\tCR_GET_PACKER_CONTEXT(pc);"
-	print "\tunsigned char *data_ptr;"
+	print("\tCR_GET_PACKER_CONTEXT(pc);")
+	print("\tunsigned char *data_ptr;")
 
 	if normalized:
 		if argtype == "Nb":
@@ -185,38 +185,38 @@ def PrintFunction( func_name, extSuffix, num_coords, argtype,
 		else:
 			abort()
 		if do_vector:
-			print "\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t)
+			print("\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t))
 		else:
-			print "\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t)
+			print("\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t))
 	else:
 		if do_vector:
-			print "\tCREATE_%dD_VFLOATS();" % num_coords
+			print("\tCREATE_%dD_VFLOATS();" % num_coords)
 		else:
-			print "\tCREATE_%dD_FLOATS();" % num_coords
+			print("\tCREATE_%dD_FLOATS();" % num_coords)
 
-	print "\tCR_GET_BUFFERED%s_POINTER( pc, %d );" % (countSuffix, packet_length)
+	print("\tCR_GET_BUFFERED%s_POINTER(pc, %d);" % (countSuffix, packet_length))
 
 	# Bounding box code
 	if isVertexAttrib:
-		print "\tif (pc->updateBBOX && index == 0)"
+		print("\tif (pc->updateBBOX && index == 0)")
 	else:
-		print "\tif (pc->updateBBOX)"
-	print "\t{"
+		print("\tif (pc->updateBBOX)")
+	print("\t{")
 	if num_coords < 4:
-		print "\t\tUPDATE_%dD_BBOX();" % num_coords
+		print("\t\tUPDATE_%dD_BBOX();" % num_coords)
 	else:
-		print "\t\tUPDATE_3D_BBOX();"
-	print "\t}"
+		print("\t\tUPDATE_3D_BBOX();")
+	print("\t}")
 
 	if isVertexAttrib:
-		print "\tif (index > 0) {"
+		print("\tif (index > 0) {")
 		t = argtype
-		print "\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % (t, num_coords)
-		print "\t\tpc->current.attribsUsedMask |= (1 << index);"
+		print("\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % (t, num_coords))
+		print("\t\tpc->current.attribsUsedMask |= (1 << index);")
 		if do_count:
-			print "\t\tpc->current.vtx_count--;"
+			print("\t\tpc->current.vtx_count--;")
 
-		print "\t}"
+		print("\t}")
 
 		fname = func_name + extSuffix
 		if do_vector:
@@ -229,41 +229,41 @@ def PrintFunction( func_name, extSuffix, num_coords, argtype,
 	if do_vector:
 		if isVertexAttrib:
 			if do_swapped:
-				print "\tWRITE_DATA( 0, GLuint, SWAP32(index) );"
+				print("\tWRITE_DATA(0, GLuint, SWAP32(index));")
 			else:
-				print "\tWRITE_DATA( 0, GLuint, index );"
+				print("\tWRITE_DATA(0, GLuint, index);")
 			counter += 4
 			argname = params[1][0]  # skip 'index' parameter
 		else:
 			argname = params[0][0]
 
 		for index in range(num_coords):
-			print WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped )
+			print(WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped ))
 			counter += apiutil.sizeof(vector_type)
 
 		if isVertexAttrib:
 			if do_vector == 2:
 				# this is a bit of a hack
-				print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" )
+				print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name + "ARB" ))
 			else:
-				print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] + "ARB" )
+				print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name[:-1] + "ARB" ))
 		else:
-			print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] )
+			print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name[:-1] ))
 	else:
 		for index in range(0,len(params)):
 			(name, type, vecSize) = params[index]
-			print WriteData( counter, type, name, do_swapped )
+			print(WriteData( counter, type, name, do_swapped ))
 			counter += apiutil.sizeof(type)
 
 		if isVertexAttrib:
-			print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" )
+			print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name + "ARB" ))
 		else:
-			print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name )
+			print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name ))
 
-	print "\tCR_UNLOCK_PACKER_CONTEXT(pc);"
+	print("\tCR_UNLOCK_PACKER_CONTEXT(pc);")
 
 
-	print '}\n'
+	print('}\n')
 
 #end PrintFunction()
 
diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py b/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py
old mode 100644
new mode 100755
index df9f514..581121d
--- a/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py
+++ b/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py
@@ -3,13 +3,14 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 import apiutil
 
 
 apiutil.CopyrightC()
 
-print """
+print("""
 
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY dispatch.py SCRIPT */
 
@@ -27,12 +28,12 @@ static SPUGenericFunction __findFunc( char *name, SPU *spu )
 
 	for (temp = spu->function_table->table ; temp->name != NULL ; temp++)
 	{
-		if (!crStrcmp( name, temp->name ) )
+		if (!crStrcmp(name, temp->name))
 		{
 			return temp->fn;
 		}
 	}
-	return __findFunc( name, spu->superSPU );
+	return __findFunc(name, spu->superSPU);
 }
 
 
@@ -42,15 +43,15 @@ static SPUGenericFunction __findFunc( char *name, SPU *spu )
 extern void __buildDispatch( SPU *spu );
 
 void __buildDispatch( SPU *spu )
-{"""
+{""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 for func_name in keys:
-	print '\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name)
-print '}'
+	print('\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name))
+print('}')
 
 
-print """
+print("""
 
 /*
  * Public function:
@@ -63,7 +64,7 @@ SPUGenericFunction crSPUFindFunction( const SPUNamedFunctionTable *table, const
 
 	for (temp = table ; temp->name != NULL ; temp++)
 	{
-		if (!crStrcmp( fname, temp->name ) )
+		if (!crStrcmp(fname, temp->name))
 		{
 			return temp->fn;
 		}
@@ -79,15 +80,15 @@ SPUGenericFunction crSPUFindFunction( const SPUNamedFunctionTable *table, const
  * It doesn't know anything about SPUs and SPU inheritance.
  */
 void crSPUInitDispatch( SPUDispatchTable *dispatch, const SPUNamedFunctionTable *table )
-{"""
+{""")
 
 for func_name in keys:
-	print '\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name)
-print '}'
+	print('\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name))
+print('}')
 
 
 
-print """
+print("""
 /*
  * Generic no-op function
  */
@@ -122,4 +123,4 @@ void crSPUInitDispatchNops(SPUDispatchTable *table)
 		}
 	}
 }
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py b/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py
old mode 100644
new mode 100755
index 972f30c..f3f15be
--- a/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py
+++ b/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py
@@ -5,6 +5,7 @@
 
 # This script generates the spu_dispatch_table.h file from gl_header.parsed
 
+from __future__ import print_function
 import sys, string
 
 import apiutil
@@ -12,7 +13,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE dispatchheader.py SCRIPT */
 
 #ifndef CR_SPU_DISPATCH_TABLE_H
@@ -26,39 +27,39 @@ print """
 
 #include "chromium.h"
 #include "state/cr_statetypes.h"
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 
-print '/* Offsets of each function within the dispatch table */'
+print('/* Offsets of each function within the dispatch table */')
 offset = 0
 for func_name in keys:
-	print '#define DISPATCH_OFFSET_%s %d' % (func_name, offset)
+	print('#define DISPATCH_OFFSET_%s %d' % (func_name, offset))
 	offset += 1
-print ''
+print('')
 
-print '/* Function typedefs */'
+print('/* Function typedefs */')
 for func_name in keys:
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
 
-	print 'typedef %s (SPU_APIENTRY *%sFunc_t)(%s);' % (return_type, func_name, apiutil.MakePrototypeString(params))
-print ''
+	print('typedef %s (SPU_APIENTRY *%sFunc_t)(%s);' % (return_type, func_name, apiutil.MakePrototypeString(params)))
+print('')
 
-print 'struct _copy_list_node;'
-print ''
-print '/* Prototype for SPU internal state load/unload callbacks. */'
-print ''
-print 'typedef int (*SPUStateFunc_t)(void *);'
-print ''
-print '/* The SPU dispatch table */'
-print 'typedef struct _spu_dispatch_table {'
+print('struct _copy_list_node;')
+print('')
+print('/* Prototype for SPU internal state load/unload callbacks. */')
+print('')
+print('typedef int (*SPUStateFunc_t)(void *);')
+print('')
+print('/* The SPU dispatch table */')
+print('typedef struct _spu_dispatch_table {')
 
 for func_name in keys:
-	print "\t%sFunc_t %s; " % ( func_name, func_name )
+	print("\t%sFunc_t %s; " % ( func_name, func_name ))
 
-print """
+print("""
 	struct _copy_list_node *copyList;
 	struct _spu_dispatch_table *copy_of;
 	int mark;
@@ -74,4 +75,4 @@ struct _copy_list_node {
 
 
 #endif /* CR_SPU_DISPATCH_TABLE_H */
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py b/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py
old mode 100644
new mode 100755
index 4b0d9ef..c73c12f
--- a/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py
+++ b/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 import apiutil
 
@@ -12,7 +13,7 @@ keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE glloader.py SCRIPT */
 #include "cr_error.h"
 #include "cr_dll.h"
@@ -73,10 +74,10 @@ static CRDLL *aglDll = NULL;
  * Add an entry to the SPUNamedFunctionTable
  */
 static int
-fillin( SPUNamedFunctionTable *entry, const char *funcName, SPUGenericFunction funcPtr )
+fillin(SPUNamedFunctionTable *entry, const char *funcName, SPUGenericFunction funcPtr)
 {
 	if (funcPtr) {
-		entry->name = crStrdup( funcName );
+		entry->name = crStrdup(funcName);
 		entry->fn = funcPtr;
 		return 1;
 	}
@@ -211,7 +212,7 @@ findExtFunction( const crOpenGLInterface *interface, const char *funcName )
 		return NULL;
 #endif
 }
-"""
+""")
 
 
 def IsExtensionFunc(func_name):
@@ -228,15 +229,15 @@ def IsExtensionFunc(func_name):
 def GenerateNop(func_name):
 	return_type = apiutil.ReturnType(func_name);
 	params = apiutil.Parameters(func_name)
-	print 'static %s GLLOADER_APIENTRY Nop%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params))
-	print '{'
+	print('static %s GLLOADER_APIENTRY Nop%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
+	print('{')
 	for (name, type, vecSize) in params:
 		if name != "":
-			print '\t(void) %s;' % name
+			print('\t(void) %s;' % name)
 	if apiutil.ReturnType(func_name) != 'void':
-		print '\treturn 0;'
-	print '}'
-	print ''
+		print('\treturn 0;')
+	print('}')
+	print('')
 
 
 
@@ -251,7 +252,7 @@ for func_name in keys:
 #
 # Generate the crLoadOpenGL() function
 #
-print """
+print("""
 void
 crUnloadOpenGL( void )
 {
@@ -280,13 +281,13 @@ int
 crLoadOpenGL( crOpenGLInterface *interface, SPUNamedFunctionTable table[] )
 {
 	static const char *coreFunctions[] = {
-"""
+""")
 
 for func_name in keys:
 	if not IsExtensionFunc(func_name):
-		print '\t\t"gl%s",' % func_name
+		print('\t\t"gl%s",' % func_name)
 
-print """
+print("""
 		NULL
 	};
 	SPUNamedFunctionTable *entry = table;
@@ -337,7 +338,7 @@ print """
 	crDebug( "Found it in %s.", !env_agl_syspath ? "default path" : env_agl_syspath );
 # endif
 #endif
-"""
+""")
 
 useful_wgl_functions = [
 	"wglGetProcAddress",
@@ -458,34 +459,34 @@ possibly_useful_glx_functions = [
     "glXGetVisualFromFBConfig",
 ]
 
-print '#ifdef WINDOWS'
+print('#ifdef WINDOWS')
 
 for fun in useful_wgl_functions:
-	print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun,fun,fun)
+	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun,fun,fun))
 
-print '#elif defined(DARWIN)'
-print '# ifndef VBOX_WITH_COCOA_QT'
+print('#elif defined(DARWIN)')
+print('# ifndef VBOX_WITH_COCOA_QT')
 for fun in useful_agl_functions:
-	print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( aglDll, "%s" );' % (fun,fun,fun)
-print '# endif'
+	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(aglDll, "%s");' % (fun,fun,fun))
+print('# endif')
 
 for fun in useful_cgl_functions:
-	print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( cglDll, "%s" );' % (fun, fun,fun)
+	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(cglDll, "%s");' % (fun, fun,fun))
 
 for fun in in_gl_functions:
-	print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun,fun)
+	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun,fun))
 
-print '#else'
-print '\t/* GLX */'
+print('#else')
+print('\t/* GLX */')
 
 # XXX merge these loops?
 for fun in useful_glx_functions:
-	print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun, fun)
+	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun, fun))
 for fun in possibly_useful_glx_functions:
-	print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun, fun)
-print '#endif'
+	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun, fun))
+print('#endif')
 
-print """
+print("""
 	if (!entry)
 		return 1; /* token value */
 
@@ -512,12 +513,14 @@ int
 crLoadOpenGLExtensions( const crOpenGLInterface *interface, SPUNamedFunctionTable table[] )
 {
 	struct extfunc {
-		const char *funcName;
-		const char *aliasName;
-		SPUGenericFunction nopFunction;
+		const char *funcName;""")
+max_aliases = apiutil.ReverseAliasesMaxCount()
+for i in range(1, 1 + max_aliases):
+	print("\t\tconst char *aliasName%d;" % i)
+print("""		SPUGenericFunction nopFunction;
 	};
 	static const struct extfunc functions[] = {
-"""
+""")
 
 for func_name in keys:
 	if IsExtensionFunc(func_name):
@@ -525,17 +528,14 @@ for func_name in keys:
 			prefix = "cr"
 		else:
 			prefix = "gl"
-		s = '\t\t{ "' + prefix + func_name + '", '
-		a = apiutil.ReverseAlias(func_name)
-		if a:
-			s += '"' + prefix + a + '", '
-		else:
-			s += 'NULL, '
-		s += '(SPUGenericFunction) Nop' + func_name + ' },'
-		print s
-
-print """
-		{ NULL, NULL, NULL}
+		s = '\t\t{ "' + prefix + func_name + '"'
+		aliases = apiutil.ReverseAliases(func_name)
+		s += ''.join([', "' + prefix + a + '"' for a in aliases]) + ', NULL' * (max_aliases - len(aliases))
+		s += ', (SPUGenericFunction) Nop' + func_name + ' },'
+		print(s)
+
+print('\t\t{ NULL%s, NULL}' % (', NULL' * max_aliases))
+print("""
 	};
 	const struct extfunc *func;
 	SPUNamedFunctionTable *entry = table;
@@ -549,11 +549,12 @@ print """
 #endif
 
 	for (func = functions; func->funcName; func++) {
-		SPUGenericFunction f = findExtFunction(interface, func->funcName);
-		if (!f && func->aliasName) {
-			f = findExtFunction(interface, func->aliasName);
-		}
-		if (!f) {
+		SPUGenericFunction f = findExtFunction(interface, func->funcName);""")
+for i in range(1, 1 + max_aliases):
+	print("""		if (!f && func->aliasName%d) {
+			f = findExtFunction(interface, func->aliasName%d);
+		}"""% (i, i))
+print("""		if (!f) {
 			f = func->nopFunction;
 		}
 		(void) fillin(entry, func->funcName + 2 , f);  /* +2 to skip "gl" */
@@ -565,10 +566,10 @@ print """
 	entry->fn = NULL;
 	return entry - table;  /* number of entries filled */
 }
-"""
+""")
 
 
-print """
+print("""
 
 #ifdef USE_OSMESA
 int crLoadOSMesa( OSMesaContext (**createContext)( GLenum format, OSMesaContext sharelist ),
@@ -591,18 +592,18 @@ int crLoadOSMesa( OSMesaContext (**createContext)( GLenum format, OSMesaContext
 	crDebug( "Found it in %s.", !env_syspath ? "default path" : env_syspath );
 
 	*createContext =  (OSMesaContext (*) ( GLenum format, OSMesaContext sharelist ))
-		crDLLGetNoError( osMesaDll, "OSMesaCreateContext" );
+		crDLLGetNoError(osMesaDll, "OSMesaCreateContext");
 
 	*makeCurrent =  (GLboolean (*) ( OSMesaContext ctx, GLubyte *buffer,
 					  GLenum type, GLsizei width, GLsizei height ))
-		crDLLGetNoError( osMesaDll, "OSMesaMakeCurrent" );
+		crDLLGetNoError(osMesaDll, "OSMesaMakeCurrent");
 
 	*destroyContext =  (void (*) ( OSMesaContext ctx))
-		crDLLGetNoError( osMesaDll, "OSMesaDestroyContext" );
+		crDLLGetNoError(osMesaDll, "OSMesaDestroyContext");
 
 	return 1;
 }
 #endif
 
-"""
+""")
 
diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py b/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py
old mode 100644
new mode 100755
index 0dc592f..7562348
--- a/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py
+++ b/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py
@@ -3,20 +3,21 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 import apiutil
 
 
 apiutil.CopyrightC()
 
-print """
+print("""
 
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spuchange.py SCRIPT */
 
 #include "cr_spu.h"
 #include "cr_error.h"
 
-void crSPUChangeInterface( SPUDispatchTable *table, void *orig_func, void *new_func )
+void crSPUChangeInterface(SPUDispatchTable *table, void *orig_func, void *new_func)
 {
 	struct _copy_list_node *temp;
 	if (table->mark == 1)
@@ -28,45 +29,45 @@ void crSPUChangeInterface( SPUDispatchTable *table, void *orig_func, void *new_f
 		return;
 	}
 	table->mark = 1;
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 for func_name in keys:
-	print '\tif ((uintptr_t)table->%s == (uintptr_t)orig_func)' % func_name
-	print '\t{'
-	print '\t\ttable->%s = (%sFunc_t)(uintptr_t)new_func;' % (func_name, func_name)
-	print '\t\tfor (temp = table->copyList ; temp ; temp = temp->next)'
-	print '\t\t{'
-	print '\t\t\tcrSPUChangeInterface( temp->copy, orig_func, new_func );'
-	print '\t\t}'
-	print '\t}'
+	print('\tif ((uintptr_t)table->%s == (uintptr_t)orig_func)' % func_name)
+	print('\t{')
+	print('\t\ttable->%s = (%sFunc_t)(uintptr_t)new_func;' % (func_name, func_name))
+	print('\t\tfor (temp = table->copyList ; temp ; temp = temp->next)')
+	print('\t\t{')
+	print('\t\t\tcrSPUChangeInterface(temp->copy, orig_func, new_func);')
+	print('\t\t}')
+	print('\t}')
 
-print """
+print("""
 	if (table->copy_of != NULL)
 	{
-		crSPUChangeInterface( table->copy_of, orig_func, new_func );
+		crSPUChangeInterface(table->copy_of, orig_func, new_func);
 	}
-	for (temp = table->copyList ; temp ; temp = temp->next)
+	for (temp = table->copyList; temp; temp = temp->next)
 	{
-		crSPUChangeInterface( temp->copy, orig_func, new_func );
+		crSPUChangeInterface(temp->copy, orig_func, new_func);
 	}
 	table->mark = 0;
-"""
-print '}'
+""")
+print('}')
 
-print """
+print("""
 void crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable)
 {
     SPUGenericFunction func;
-"""
+""")
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 for func_name in keys:
-    print '\tfunc = crSPUFindFunction(newtable, "%s");' % func_name
-    print '\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name
-    print '\t{'
-    print '\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % (func_name, func_name)
-    print '\t\tcrSPUChangeInterface(dispatch, (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % func_name
-    print '\t}\n'
-print """
+    print('\tfunc = crSPUFindFunction(newtable, "%s");' % func_name)
+    print('\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name)
+    print('\t{')
+    print('\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % (func_name, func_name))
+    print('\t\tcrSPUChangeInterface(dispatch, (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % func_name)
+    print('\t}\n')
+print("""
 }
-"""
\ No newline at end of file
+""")
diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py b/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py
old mode 100644
new mode 100755
index 4da6b53..bf1990a
--- a/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py
+++ b/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py
@@ -3,13 +3,14 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 import apiutil
 
 
 apiutil.CopyrightC()
 
-print """
+print("""
 
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spucopy.py SCRIPT */
 
@@ -18,16 +19,16 @@ print """
 
 void crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src )
 {
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 for func_name in keys:
-	print '\tdst->%s = src->%s;' % (func_name, func_name)
+	print('\tdst->%s = src->%s;' % (func_name, func_name))
 
 # if the destination is already a copy of something, we'd better make sure
 # that we take it off its source's copy list first.
 
-print """
+print("""
 	if (dst->copy_of != NULL)
 	{
 		/*
@@ -76,4 +77,4 @@ print """
 		src->copyList = copynode;
 	}
 }
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/convert.py b/src/VBox/GuestHost/OpenGL/state_tracker/convert.py
index 617cb09..1adbf4e 100755
--- a/src/VBox/GuestHost/OpenGL/state_tracker/convert.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/convert.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 # Two different paths to the packer and opengl_stub directories since this
@@ -16,7 +17,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print '''
+print('''
 #include "state/cr_statetypes.h"
 
 static double __read_double( const void *src )
@@ -27,20 +28,20 @@ static double __read_double( const void *src )
     ((unsigned int *) &d)[1] = ui[1];
     return d;
 }
-'''
+''')
 
-for k in gltypes.keys():
+for k in sorted(gltypes.keys()):
 	for i in range(1,5):
-		print 'static void __convert_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k]['type'])
+		print('static void __convert_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k]['type']))
 		if k == 'd':
 		  for j in range(i-1):
-		    print '\t*dst++ = (GLfloat) __read_double(src++);'
-		  print '\t*dst = (GLfloat) __read_double(src);'
+		    print('\t*dst++ = (GLfloat) __read_double(src++);')
+		  print('\t*dst = (GLfloat) __read_double(src);')
 		else:
 		  for j in range(i-1):
-		    print '\t*dst++ = (GLfloat) *src++;';
-		  print '\t*dst = (GLfloat) *src;';
-		print '}\n';
+		    print('\t*dst++ = (GLfloat) *src++;')
+		  print('\t*dst = (GLfloat) *src;')
+		print('}\n')
 
 scale = {
 	'ub' : 'CR_MAXUBYTE',
@@ -53,22 +54,22 @@ scale = {
 	'd'  : ''
 }
 
-for k in gltypes.keys():
+for k in sorted(gltypes.keys()):
 	if k != 'f' and k != 'd' and k != 'l':
 		if k[0:1] == "N":
 			k2 = k[1:]
 		else:
 			k2 = k
 		for i in range(1,5):
-			print 'static void __convert_rescale_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k2]['type'])
+			print('static void __convert_rescale_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k2]['type']))
 			for j in range(i-1):
-				print '\t*dst++ = ((GLfloat) *src++) / %s;' % scale[k2]
-			print '\t*dst = ((GLfloat) *src) / %s;' % scale[k2]
-			print '}\n'
+				print('\t*dst++ = ((GLfloat) *src++) / %s;' % scale[k2])
+			print('\t*dst = ((GLfloat) *src) / %s;' % scale[k2])
+			print('}\n')
 
-print '''
+print('''
 
 static void __convert_boolean (GLboolean *dst, const GLboolean *src) {
 	*dst = *src;
 }
-'''
+''')
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py b/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py
index 7103ed4..c4cae06 100755
--- a/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -33,7 +34,7 @@ for line in input.readlines():
 
 apiutil.CopyrightC()
 
-print """#include "cr_blitter.h"
+print("""#include "cr_blitter.h"
 #include "cr_spu.h"
 #include "chromium.h"
 #include "cr_error.h"
@@ -51,7 +52,7 @@ print """#include "cr_blitter.h"
 #include <stdio.h>
 
 #ifdef VBOX_WITH_CRDUMPER
-"""
+""")
 
 from get_sizes import *;
 
@@ -68,7 +69,7 @@ enableprops = apiutil.ParamProps("Enable")
 #        except KeyError:
 #            print "//%s" % prop
 #
-print """
+print("""
 static void crRecDumpPrintVal(CR_DUMPER *pDumper, struct nv_struct *pDesc, float *pfData)
 {
     char aBuf[4096];
@@ -93,25 +94,19 @@ void crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx)
 void crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx)
 {
     GLboolean fEnabled;
-"""
-keys = params.keys()
-keys.sort();
+""")
+for pname in sorted(params.keys()):
+    print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname)
+    print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname)
 
-for pname in keys:
-    print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
-    print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
-
-keys = extended_params.keys();
-keys.sort()
-
-for pname in keys:
+for pname in sorted(extended_params.keys()):
     (srctype,ifdef,fields) = extended_params[pname]
     ext = ifdef[3:]  # the extension name with the "GL_" prefix removed
     ext = ifdef
-    print '#ifdef CR_%s' % ext
-    print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
-    print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
-    print '#endif /* CR_%s */' % ext
+    print('#ifdef CR_%s' % ext)
+    print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname)
+    print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname)
+    print('#endif /* CR_%s */' % ext)
 
 #print "//missing enable props:"
 #for prop in enableprops:
@@ -123,10 +118,10 @@ for pname in keys:
 #        except KeyError:
 #            print "//%s" % prop
 #
-print """
+print("""
 }
 #endif
-"""
+""")
 
 texenv_mappings = {
     'GL_TEXTURE_ENV' : [
@@ -183,75 +178,72 @@ texparam_names = [
     'GL_GENERATE_MIPMAP'
 ]
 
-print """
+print("""
 void crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget)
 {
     GLfloat afBuf[4];
     char acBuf[1024];
     unsigned int cComponents;
     crDmpStrF(pRec->pDumper, "==TEX_PARAM for target(0x%x)==", enmTarget);
-"""
+""")
 for pname in texparam_names:
-    print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
-    print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
-    print "\tmemset(afBuf, 0, sizeof (afBuf));"
-    print "\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname
-    print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
-    print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
-print """
+    print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
+    print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
+    print("\tmemset(afBuf, 0, sizeof (afBuf));")
+    print("\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname)
+    print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
+    print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
+print("""
     crDmpStrF(pRec->pDumper, "==Done TEX_PARAM for target(0x%x)==", enmTarget);
 }
-"""
+""")
 
-print """
+print("""
 void crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx)
 {
     GLfloat afBuf[4];
     char acBuf[1024];
     unsigned int cComponents;
     crDmpStrF(pRec->pDumper, "==TEX_ENV==");
-"""
-
-keys = texenv_mappings.keys()
-keys.sort();
+""")
 
-for target in keys:
-    print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target
+for target in sorted(texenv_mappings.keys()):
+    print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target)
     values = texenv_mappings[target]
     for pname in values:
-        print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
-        print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
-        print "\tmemset(afBuf, 0, sizeof (afBuf));"
-        print "\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname)
-        print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
-        print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
-    print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target
-print """
+        print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
+        print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
+        print("\tmemset(afBuf, 0, sizeof (afBuf));")
+        print("\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname))
+        print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
+        print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
+    print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target)
+print("""
     crDmpStrF(pRec->pDumper, "==Done TEX_ENV==");
 }
-"""
+""")
 
 
-print """
+print("""
 void crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx)
 {
     GLdouble afBuf[4];
     char acBuf[1024];
     unsigned int cComponents;
     crDmpStrF(pRec->pDumper, "==TEX_GEN==");
-"""
+""")
 
 for coord in texgen_coords:
-    print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord
+    print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord)
     for pname in texgen_names:
-        print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
-        print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
-        print "\tmemset(afBuf, 0, sizeof (afBuf));"
-        print "\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname)
-        print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
-        print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
-    print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord
-print """
+        print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
+        print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
+        print("\tmemset(afBuf, 0, sizeof (afBuf));")
+        print("\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname))
+        print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
+        print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
+    print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord)
+print("""
     crDmpStrF(pRec->pDumper, "==Done TEX_GEN==");
 }
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py b/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py
old mode 100644
new mode 100755
index fa3f9a7..6c3e91d
--- a/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py
@@ -3,33 +3,34 @@
 #
 # See the file LICENSE.txt for information on redistributing this software
 
+from __future__ import print_function
 import sys
 
 def main():
 	name = sys.argv[1]
 	Name = sys.argv[2]
 
-	print """/* This code is AUTOGENERATED!!! */
+	print("""/* This code is AUTOGENERATED!!! */
 
 #include "state.h"
-#include "state_internals.h\""""
+#include "state_internals.h\"""")
 
-	print """
+	print("""
 void crState%(Name)sDiff(CR%(Name)sBits *b, CRbitvalue *bitID,
 		CRContext *fromCtx, CRContext *toCtx)
 {
 	CR%(Name)sState *from = &(fromCtx->%(name)s);
-	CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()
+	CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars())
 	gendiffcode("state_%s.txt"%(name.lower()), name, docopy=1, doinvalid=0)
-	print """}
+	print("""}
 
 void crState%(Name)sSwitch(CR%(Name)sBits *b, CRbitvalue *bitID,
 		CRContext *fromCtx, CRContext *toCtx)
 {
 	CR%(Name)sState *from = &(fromCtx->%(name)s);
-	CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()
+	CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars())
 	gendiffcode("state_%s.txt"%(Name.lower()), Name, docopy=0, doinvalid=1)
-	print "}\n"
+	print("}\n")
 
 def gendiffcode(fname, state_name, docopy, doinvalid):
 	target = "to"
@@ -54,14 +55,14 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 
 	FILE = open(sys.argv[3]+"/"+fname, "r")
 
-	print """	unsigned int j, i;
+	print("""	unsigned int j, i;
 	CRbitvalue nbitID[CR_MAX_BITARRAY];
-	for (j=0;j<CR_MAX_BITARRAY;j++)
+	for (j = 0; j<CR_MAX_BITARRAY; j++)
 		nbitID[j] = ~bitID[j];
-	i = 0; /* silence compiler */"""
+	i = 0; /* silence compiler */""")
 
 	import re
-	for line in FILE.xreadlines():
+	for line in FILE:
 		line = line.rstrip()
 
 		if re.match("#", line):
@@ -86,7 +87,7 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 			text = m.group(1)
 			if re.search("}", line):
 				tab = tab[:-1]
-			print tab+text
+			print(tab+text)
 			if re.search("{", line):
 				tab = tab+"\t"
 			continue
@@ -108,12 +109,12 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 
 		if re.search("%flush", line):
 			if current_guard != "":
-				print tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()
+				print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars())
 				tab = tab[:-1]
-				print tab+"}"
+				print(tab+"}")
 			if docopy and current_dependency != "":
 				tab = tab[:-1]
-				print tab+"}"
+				print(tab+"}")
 			current_guard = ""
 			current_dependency = ""
 		if re.search("%", line):
@@ -126,38 +127,38 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 
 ## Close the guardbit and dependency
 		if current_guard != "" and current_guard != guardbit:
-			print tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()
+			print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars())
 			tab = tab[:-1]
-			print tab+"}"
+			print(tab+"}")
 		if docopy and current_dependency != "" and current_dependency != dependency:
 			tab = tab[:-1]
-			print tab+"}"
+			print(tab+"}")
 
 ## Open the dependency if
 		if docopy and current_dependency != dependency and dependency != "":
-			print tab+"if (%(target)s->%(dependency)s)\n%(tab)s{"%vars()
+			print(tab+"if (%(target)s->%(dependency)s)\n%(tab)s{"%vars())
 			tab = tab+"\t"
 			current_dependency = dependency
 		
 ## Open the guard if
 		if docopy and current_dependency != dependency and dependency != "":
-			print tab+"if ($(target)s->%(dependency)s)\n%(tab)s{"%vars()
+			print(tab+"if ($(target)s->%(dependency)s)\n%(tab)s{"%vars())
 			tab = tab+"\t"
 		
 		if current_guard != guardbit and guardbit != "":
-			print tab+"if (CHECKDIRTY(%(bit)s->%(guardbit)s, bitID))\n%(tab)s{"%vars()
+			print(tab+"if (CHECKDIRTY(%(bit)s->%(guardbit)s, bitID))\n%(tab)s{"%vars())
 			tab = tab+"\t"
 			if members[0] != "*" and guardbit[0:6] == "enable":
-				print tab+"glAble able[2];"
-				print tab+"able[0] = diff_api.Disable;"
-				print tab+"able[1] = diff_api.Enable;"
+				print(tab+"glAble able[2];")
+				print(tab+"able[0] = diff_api.Disable;")
+				print(tab+"able[1] = diff_api.Enable;")
 
 		current_dependency = dependency
 		current_guard = guardbit
 
 ## Handle text dump
 		if members[0] == "*":
-			print tab+members[1:]
+			print(tab+members[1:])
 		else:
 			## Parse the members variable
 			mainelem = re.split(",", members)
@@ -180,28 +181,28 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 				first = 1
 				for elem in elems:
 					if first != 1:
-						print " ||\n"+tab+"    ",
+						print(" ||\n"+tab+"    ", end="")
 					first = 0
 					sys.stdout.write("%(current)s->%(elem)s != %(target)s->%(elem)s"%vars())
-				print ")\n"+tab+"{"
+				print(")\n"+tab+"{")
 				tab = tab+"\t"
 
 ## Handle text function 
 			if func[0] == "*":
 				func = func[1:]
-				print tab+func
+				print(tab+func)
 			else:
 				if func != "":
 ## Call the glhw function
 					if guardbit[0:6] == "enable":
-						print tab+"able["+target+"->"+elems[0]+"]("+func+");"
+						print(tab+"able["+target+"->"+elems[0]+"]("+func+");")
 					elif guardbit == "extensions":
-						print tab+"crState$state_name",
+						print(tab+"crState$state_name",end="")
 						if docopy == 1:
-							print "Diff",
+							print("Diff",end="")
 						else:
-							print "Switch",
-						print "Extensions( from, to );"
+							print("Switch",end="")
+						print("Extensions(from, to);")
 					else:
 						funcargs = re.split(",", func)
 						#print "// funcargs:",funcargs
@@ -210,21 +211,21 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 						if func[-1] == "v":
 							v_type = func[-2:-1]
 							num_elems = len(elems)
-							print tab+v_types[v_type]+" varg["+str(num_elems)+"];"
+							print(tab+v_types[v_type]+" varg["+str(num_elems)+"];")
 							i = 0
 							for elem in elems:
-								print tab+"varg["+str(i)+"] = "+target+"->"+elem+";"
+								print(tab+"varg["+str(i)+"] = "+target+"->"+elem+";")
 								i += 1
 						elif func[-3:] == "vNV":
 							v_type = func[-4:-3]
 							num_elems = len(elems)
-							print tab+v_types[v_type]+" varg["+str(num_elems)+"];"
+							print(tab+v_types[v_type]+" varg["+str(num_elems)+"];")
 							i = 0
 							for elem in elems:
-								print tab+"varg["+str(i)+"] = "+target+"->"+elem+";"
+								print(tab+"varg["+str(i)+"] = "+target+"->"+elem+";")
 								i += 1
 
-						sys.stdout.write(tab+"diff_api.%(func)s ("%vars())
+						sys.stdout.write(tab+"diff_api.%(func)s("%vars())
 						for funcarg in funcargs:
 							sys.stdout.write(funcarg+", ")
 
@@ -238,35 +239,35 @@ def gendiffcode(fname, state_name, docopy, doinvalid):
 									sys.stdout.write(",\n"+tab+"    ")
 								first = 0
 								sys.stdout.write(target+"->"+elem)
-						print ");"
+						print(");")
 
 ## Do the sync if necessary
 			if docopy and guardbit != "extensions":
 				for elem in  mainelem:
-					print tab+current+"->"+elem+" = "+target+"->"+elem+";"
+					print(tab+current+"->"+elem+" = "+target+"->"+elem+";")
 
 			## Do the clear if necessary
 			if doinvalid:
 				if guardbit != "":
-					print tab+"FILLDIRTY(%(bit)s->%(guardbit)s);"%vars()
-				print tab+"FILLDIRTY(%(bit)s->dirty);"%vars()
+					print(tab+"FILLDIRTY(%(bit)s->%(guardbit)s);"%vars())
+				print(tab+"FILLDIRTY(%(bit)s->dirty);"%vars())
 				if extrabit != "":
-					print tab+"FILLDIRTY(%(extrabit)s->dirty);"%vars()
+					print(tab+"FILLDIRTY(%(extrabit)s->dirty);"%vars())
 
 			## Close the compare
 			if guardbit != "extensions":
 				tab = tab[:-1]
-				print tab+"}"
+				print(tab+"}")
 
 ## Do final closures
 	if current_guard != "":
-		print tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()
+		print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars())
 		tab = tab[:-1]
-		print tab+"}"
+		print(tab+"}")
 	if docopy and current_dependency != "":
 		tab = tab[:-1]
-		print tab+"} /*%(current_dependency)s*/"%vars()
+		print(tab+"} /*%(current_dependency)s*/"%vars())
 
-	print tab+"CLEARDIRTY(%(bit)s->dirty, nbitID);"%vars()
+	print(tab+"CLEARDIRTY(%(bit)s->dirty, nbitID);"%vars())
 
 main()
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py b/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py
old mode 100644
new mode 100755
index c9a3245..d33e946
--- a/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py
@@ -3,6 +3,8 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
+
 num_components = {
 	'GL_AMBIENT' : 4, 
 	'GL_DIFFUSE' : 4,
@@ -113,25 +115,21 @@ num_extended_components = {
 	'GL_COORD_REPLACE_ARB': (1, 'CR_ARB_point_sprite'),
 }
 
-print """unsigned int crStateHlpComponentsCount( GLenum pname )
+print("""unsigned int crStateHlpComponentsCount( GLenum pname )
 {
 	switch( pname )
 	{
-"""
-comps = num_components.keys();
-comps.sort();
-for comp in comps:
-	print '\t\t\tcase %s: return %d;' % (comp,num_components[comp])
+""")
+for comp in sorted(num_components.keys()):
+	print('\t\t\tcase %s: return %d;' % (comp,num_components[comp]))
 
-comps = num_extended_components.keys();
-comps.sort();
-for comp in comps:
+for comp in sorted(num_extended_components.keys()):
 	(nc, ifdef) = num_extended_components[comp]
-	print '#ifdef %s' % ifdef
-	print '\t\t\tcase %s: return %d;' % (comp,nc)
-	print '#endif /* %s */' % ifdef
+	print('#ifdef %s' % ifdef)
+	print('\t\t\tcase %s: return %d;' % (comp,nc))
+	print('#endif /* %s */' % ifdef)
 
-print """
+print("""
 		default:
 			crError( "Unknown parameter name in crStateHlpComponentsCount: %d", (int) pname );
 			break;
@@ -139,6 +137,6 @@ print """
 	/* NOTREACHED */
 	return 0;
 }
-"""
+""")
 
 
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py
index d118bcc..252c662 100755
--- a/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 from pack_currenttypes import *
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print '''
+print('''
 #include "state/cr_currentpointers.h"
 #include "state.h"
 
@@ -21,30 +22,30 @@ print '''
 #endif
 
 typedef void (*convert_func) (GLfloat *, const unsigned char *);
-'''
+''')
 
 import convert
 
-for k in current_fns.keys():
+for k in sorted(current_fns.keys()):
 	name = k
 	name = '%s%s' % (k[:1].lower(),k[1:])
 	ucname = k.upper()
 	num_members = len(current_fns[k]['default']) + 1
 
-	print '#define VPINCH_CONVERT_%s(op,data,dst) \\' % ucname
-	print '{\\'
-	print '\tGLfloat vdata[%d] = {' % num_members,
+	print('#define VPINCH_CONVERT_%s(op,data,dst) \\' % ucname)
+	print('{\\')
+	print('\tGLfloat vdata[%d] = {' % num_members, end=' ')
 
 ## Copy dst data into vdata
 	i = 0;
 	for defaultvar in current_fns[k]['default']:
-		print '%d' % defaultvar,
+		print('%d' % defaultvar, end=' ')
 		if i != num_members:
-			print ',',
+			print(',', end=' ')
 		i += 1
-	print '};\\'
+	print('};\\')
 
-	print '\tswitch (op) { \\'
+	print('\tswitch (op) { \\')
 	for type in current_fns[k]['types']:
 		if type[0:1] == "N":
 			normalize = 1
@@ -54,28 +55,28 @@ for k in current_fns.keys():
 		for size in current_fns[k]['sizes']:
 			uctype = type.upper()
 			if ucname == 'EDGEFLAG':
-				print '\tcase CR_%s_OPCODE: \\' % ucname
+				print('\tcase CR_%s_OPCODE: \\' % ucname)
 			else:
-				print '\tcase CR_%s%d%s_OPCODE: \\' % (ucname,size,uctype)
+				print('\tcase CR_%s%d%s_OPCODE: \\' % (ucname,size,uctype))
 			
 			if (ucname == 'COLOR' or ucname == 'NORMAL' or ucname == 'SECONDARYCOLOR' or normalize) and type != 'f' and type != 'd':
-				print '\t\t__convert_rescale_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type'])
+				print('\t\t__convert_rescale_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type']))
 			else:
-				print '\t\t__convert_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type'])
-			print '\t\tbreak; \\'
+				print('\t\t__convert_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type']))
+			print('\t\tbreak; \\')
 
-	print '\tdefault: \\'
-	print '\t\tcrSimpleError ( "Unknown opcode in VPINCH_CONVERT_%s" ); \\' % ucname
-	print '\t}\\'
+	print('\tdefault: \\')
+	print('\t\tcrSimpleError ( "Unknown opcode in VPINCH_CONVERT_%s" ); \\' % ucname)
+	print('\t}\\')
 
 	i = 0
 	for member in current_fns[k]['members']:
-		print '\t(dst).%s = vdata[%d];\\' % (member,i)
+		print('\t(dst).%s = vdata[%d];\\' % (member,i))
 		i += 1
 
-	print '}\n'
+	print('}\n')
 
-print '''
+print('''
 
 void crStateCurrentRecover( void )
 {
@@ -186,17 +187,17 @@ void crStateCurrentRecover( void )
 	c->edgeFlagPre = c->edgeFlag;
 	c->colorIndexPre = c->colorIndex;
 
-'''
+''')
 
-for k in current_fns.keys():
-	print '\t/* %s */' % k
-	print '\tv=NULL;'
+for k in sorted(current_fns.keys()):
+	print('\t/* %s */' % k)
+	print('\tv = NULL;')
 	name = '%s%s' % (k[:1].lower(),k[1:])
 
 	indent = ""
-	if current_fns[k].has_key( 'array' ):
-		print '\tfor (i = 0 ; i < %s ; i++)' % current_fns[k]['array']
-		print '\t{'
+	if 'array' in current_fns[k]:
+		print('\tfor (i = 0; i < %s; i++)' % current_fns[k]['array'])
+		print('\t{')
 		indent += "\t"
 	for type in current_fns[k]['types']:
 		if type[0:1] == "N":
@@ -207,68 +208,68 @@ for k in current_fns.keys():
 			type2 = type
 		for size in current_fns[k]['sizes']:
 			ptr = '%s->%s%d' % (name, type, size )
-			if current_fns[k].has_key( 'array' ):
+			if 'array' in current_fns[k]:
 				ptr += "[i]"
-			print '%s\tif (v < %s)' % (indent, ptr)
-			print '%s\t{' % indent
-			print '%s\t\tv = %s;' % (indent, ptr)
+			print('%s\tif (v < %s)' % (indent, ptr))
+			print('%s\t{' % indent)
+			print('%s\t\tv = %s;' % (indent, ptr))
 			if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l':
-				print '%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)
+				print('%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size))
 			else:
-				print '%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)
-			print '%s\t}' % indent
-	print ''
-	print '%s\tif (v != NULL) {' % indent
-	if current_fns[k].has_key( 'array' ):
+				print('%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size))
+			print('%s\t}' % indent)
+	print('')
+	print('%s\tif (v != NULL) {' % indent)
+	if 'array' in current_fns[k]:
 		if k == 'TexCoord':
-			print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)
+			print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name))
 		else:
-			print '%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)
+			print('%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name))
 	else:
 		if k == 'Normal':
-			print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)
+			print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name))
 		elif k == 'FogCoord':
-			print '%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name)
+			print('%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name))
 		elif k == 'Color':
-			print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)
+			print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name))
 		elif k == 'SecondaryColor':
-			print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name)
+			print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name))
 		elif k == 'TexCoord':
-			print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)
+			print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name))
 		elif k == 'Index':
-			print '%s\t\tc->colorIndex =  %s_default;' % (indent,name)
+			print('%s\t\tc->colorIndex =  %s_default;' % (indent,name))
 		elif k == 'EdgeFlag':
-			print '%s\t\tc->edgeFlag =  %s_default;' % (indent,name)
+			print('%s\t\tc->edgeFlag =  %s_default;' % (indent,name))
 		else:
-			print '%s\t\tc->%s = %s_default;' % (indent,name,name)
+			print('%s\t\tc->%s = %s_default;' % (indent,name,name))
 	if k == 'EdgeFlag':
-		print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)
+		print('%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent))
 		dirtyVar = 'cb->edgeFlag'
 	elif k == 'Normal':
-		print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)
+		print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent))
 		dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'
 	elif k == 'TexCoord':
-		print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)
+		print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent))
 		dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'
 	elif k == 'Color':
-		print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)
+		print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent))
 		dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'
 	elif k == 'Index':
-		print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)
+		print('%s\t\tconvert(&(c->colorIndex), v);' % (indent))
 		dirtyVar = 'cb->colorIndex'
 	elif k == 'SecondaryColor':
-		print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)
+		print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent))
 		dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'
 	elif k == 'FogCoord':
-		print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)
+		print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent))
 		dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'
 	elif k == 'VertexAttrib':
-		print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)
+		print('%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent))
 		dirtyVar = 'cb->vertexAttrib[i]'
 	else:
 		assert 0  # should never get here
 
-	print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)
+	print('%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar))
 
 #	if current_fns[k].has_key( 'array' ):
 #		print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name)
@@ -277,17 +278,17 @@ for k in current_fns.keys():
 
 
 
-	print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent
-	print '%s\t}' % indent
-	if current_fns[k].has_key( 'array' ):
-		print '%s\t%s->ptr[i] = v;' % (indent, name )
+	print('%s\t\tDIRTY(cb->dirty, nbitID);' % indent)
+	print('%s\t}' % indent)
+	if 'array' in current_fns[k]:
+		print('%s\t%s->ptr[i] = v;' % (indent, name ))
 	else:
-		print '%s\t%s->ptr = v;' % (indent, name )
-	if current_fns[k].has_key( 'array' ):
-		print '\t}'
-print '}'
+		print('%s\t%s->ptr = v;' % (indent, name ))
+	if 'array' in current_fns[k]:
+		print('\t}')
+print('}')
 
-print '''
+print('''
 
 void crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers  *current)
 {
@@ -364,21 +365,21 @@ void crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers  *current)
     (void) __convert_Nub4;
 
 
-'''
+''')
 
-for k in current_fns_new.keys():
-    print '\t/* %s */' % k
-    print '\tif (current->changed%s)' % k
-    print '\t{'
-    print '\t\tv=NULL;'
+for k in sorted(current_fns_new.keys()):
+    print('\t/* %s */' % k)
+    print('\tif (current->changed%s)' % k)
+    print('\t{')
+    print('\t\tv=NULL;')
     name = '%s%s' % (k[:1].lower(),k[1:])
 
     indent = ""
-    if current_fns_new[k].has_key( 'array' ):
-        print '\t\tfor (i = 0 ; i < %s ; i++)' % current_fns_new[k]['array']
-        print '\t\t{'
+    if 'array' in current_fns_new[k]:
+        print('\t\tfor (i = 0; i < %s; i++)' % current_fns_new[k]['array'])
+        print('\t\t{')
         indent += "\t\t"
-        print '\t\tif (!(current->changed%s & (1 << i))) continue;' % k
+        print('\t\tif (!(current->changed%s & (1 << i))) continue;' % k)
     for type in current_fns_new[k]['types']:
         if type[0:1] == "N":
             normalized = 1
@@ -388,76 +389,76 @@ for k in current_fns_new.keys():
             type2 = type
         for size in current_fns_new[k]['sizes']:
             ptr = '%s->%s%d' % (name, type, size )
-            if current_fns_new[k].has_key( 'array' ):
+            if 'array' in current_fns_new[k]:
                 ptr += "[i]"
-            print '#ifdef DEBUG_misha'
-            print '%s\tif (%s)' % (indent, ptr)
-            print '%s\t{' % (indent)
-            print '%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr)
-            print '%s\t\t--pTst;' % (indent)
-            print '%s\t\tAssert((*pTst) == i);' % (indent)
-            print '%s\t}' % (indent)
-            print '#endif'
-            print '%s\tif (v < %s)' % (indent, ptr)
-            print '%s\t{' % indent
-            print '%s\t\tv = %s;' % (indent, ptr)
+            print('#ifdef DEBUG_misha')
+            print('%s\tif (%s)' % (indent, ptr))
+            print('%s\t{' % (indent))
+            print('%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr))
+            print('%s\t\t--pTst;' % (indent))
+            print('%s\t\tAssert((*pTst) == i);' % (indent))
+            print('%s\t}' % (indent))
+            print('#endif')
+            print('%s\tif (v < %s)' % (indent, ptr))
+            print('%s\t{' % indent)
+            print('%s\t\tv = %s;' % (indent, ptr))
             if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l':
-                print '%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)
+                print('%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size))
             else:
-                print '%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)
-            print '%s\t}' % indent
-    print ''
-    print '%s\tif (v != NULL) {' % indent
-    if current_fns_new[k].has_key( 'array' ):
+                print('%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size))
+            print('%s\t}' % indent)
+    print('')
+    print('%s\tif (v != NULL) {' % indent)
+    if 'array' in current_fns_new[k]:
         if k == 'TexCoord':
-            print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)
+            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name))
         else:
-            print '%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)
+            print('%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name))
     else:
         if k == 'Normal':
-            print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)
+            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name))
         elif k == 'FogCoord':
-            print '%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name)
+            print('%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name))
         elif k == 'Color':
-            print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)
+            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name))
         elif k == 'SecondaryColor':
-            print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name)
+            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name))
         elif k == 'TexCoord':
-            print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)
+            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name))
         elif k == 'Index':
-            print '%s\t\tc->colorIndex =  %s_default;' % (indent,name)
+            print('%s\t\tc->colorIndex =  %s_default;' % (indent,name))
         elif k == 'EdgeFlag':
-            print '%s\t\tc->edgeFlag =  %s_default;' % (indent,name)
+            print('%s\t\tc->edgeFlag =  %s_default;' % (indent,name))
         else:
-            print '%s\t\tc->%s = %s_default;' % (indent,name,name)
+            print('%s\t\tc->%s = %s_default;' % (indent,name,name))
     if k == 'EdgeFlag':
-        print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)
+        print('%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent))
         dirtyVar = 'cb->edgeFlag'
     elif k == 'Normal':
-        print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)
+        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent))
         dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'
     elif k == 'TexCoord':
-        print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)
+        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent))
         dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'
     elif k == 'Color':
-        print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)
+        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent))
         dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'
     elif k == 'Index':
-        print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)
+        print('%s\t\tconvert(&(c->colorIndex), v);' % (indent))
         dirtyVar = 'cb->colorIndex'
     elif k == 'SecondaryColor':
-        print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)
+        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent))
         dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'
     elif k == 'FogCoord':
-        print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)
+        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent))
         dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'
     elif k == 'VertexAttrib':
-        print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)
+        print('%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent))
         dirtyVar = 'cb->vertexAttrib[i]'
     else:
         assert 0  # should never get here
 
-    print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)
+    print('%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar))
 
 #   if current_fns_new[k].has_key( 'array' ):
 #       print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name)
@@ -466,15 +467,15 @@ for k in current_fns_new.keys():
 
 
 
-    print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent
-    print '%s\t}' % indent
-    if current_fns_new[k].has_key( 'array' ):
-        print '%s\t%s->ptr[i] = v;' % (indent, name )
+    print('%s\t\tDIRTY(cb->dirty, nbitID);' % indent)
+    print('%s\t}' % indent)
+    if 'array' in current_fns_new[k]:
+        print('%s\t%s->ptr[i] = v;' % (indent, name ))
     else:
-        print '%s\t%s->ptr = v;' % (indent, name )
-    if current_fns_new[k].has_key( 'array' ):
-        print '\t\t}'
-        print '\t\tcurrent->changed%s = 0;' % k
-        print '\t}'
-print '\tcrStateResetCurrentPointers(current);'
-print '}'
+        print('%s\t%s->ptr = v;' % (indent, name ))
+    if 'array' in current_fns_new[k]:
+        print('\t\t}')
+        print('\t\tcurrent->changed%s = 0;' % k)
+        print('\t}')
+print('\tcrStateResetCurrentPointers(current);')
+print('}')
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py
old mode 100644
new mode 100755
index 19436d5..ebf1b37
--- a/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py
@@ -4,6 +4,7 @@
 # See the file LICENSE.txt for information on redistributing this software.
 
 
+from __future__ import print_function
 import sys
 
 sys.path.append( "../glapi_parser" )
@@ -12,7 +13,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY state_funcs.py SCRIPT */
 #ifndef CR_STATE_FUNCS_H
 #define CR_STATE_FUNCS_H
@@ -32,30 +33,30 @@ print """
 extern "C" {
 #endif
 
-#define STATE_UNUSED(x) ((void)x)"""
+#define STATE_UNUSED(x) ((void)x)""")
 
 
 
 for func_name in apiutil.AllSpecials( "state" ):
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
-	print 'DECLEXPORT(%s) STATE_APIENTRY crState%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
+	print('DECLEXPORT(%s) STATE_APIENTRY crState%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
 
 for func_name in apiutil.AllSpecials( "state_feedback" ):
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
-	print 'DECLEXPORT(%s) STATE_APIENTRY crStateFeedback%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
+	print('DECLEXPORT(%s) STATE_APIENTRY crStateFeedback%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
 
 for func_name in apiutil.AllSpecials( "state_select" ):
 	return_type = apiutil.ReturnType(func_name)
 	params = apiutil.Parameters(func_name)
-	print 'DECLEXPORT(%s) STATE_APIENTRY crStateSelect%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
+	print('DECLEXPORT(%s) STATE_APIENTRY crStateSelect%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
 
 
-print """
+print("""
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* CR_STATE_FUNCS_H */
-"""
+""")
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py
index 759c30d..d5238c4 100755
--- a/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys, re, string
 import apiutil
 
@@ -20,7 +21,7 @@ for line in input.readlines():
 	if match:
 		type = match.group(1)
 		pname = match.group(2)
-		fields = string.split( match.group(3) )
+		fields = match.group(3).split()
 		params[pname] = ( type, fields )
 
 input = open( sys.argv[2]+"/state_extensions_get.txt", 'r' )
@@ -32,60 +33,60 @@ for line in input.readlines():
 		type = match.group(1)
 		pname = match.group(2)
 		ifdef = match.group(3)
-		fields = string.split( match.group(4) )
+		fields = match.group(4).split()
 		extended_params[pname] = ( type, ifdef, fields )
 
 convert = {
 		   'GLenum' : {
-			  'Boolean' : '(GLboolean) ( %s != 0 )',
+			  'Boolean' : '(GLboolean) (%s != 0)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLboolean' : {
-			  'Boolean' : '(GLboolean) ( %s != 0 )',
+			  'Boolean' : '(GLboolean) (%s != 0)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLint'  : {
-			  'Boolean' : '(GLboolean) ( %s != 0 )',
+			  'Boolean' : '(GLboolean) (%s != 0)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLuint'  : {
-			  'Boolean' : '(GLboolean) ( %s != 0 )',
+			  'Boolean' : '(GLboolean) (%s != 0)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLfloat' : {
-			  'Boolean' : '(GLboolean) ( %s != 0.0f )',
+			  'Boolean' : '(GLboolean) (%s != 0.0f)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '%s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLdouble' : {
-			  'Boolean' : '(GLboolean) ( %s != 0.0 )',
+			  'Boolean' : '(GLboolean) (%s != 0.0)',
 			  'Double'  : '%s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLdefault' : {
-			  'Boolean' : '(GLboolean) ( %s != (GLdefault) 0.0 )',
+			  'Boolean' : '(GLboolean) (%s != (GLdefault) 0.0)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '(GLint) %s'
 			 },
 		   'GLclampd' : {
-			  'Boolean' : '(GLboolean) ( %s != 0.0 )',
+			  'Boolean' : '(GLboolean) (%s != 0.0)',
 			  'Double'  : '%s',
 			  'Float'   : '(GLfloat) %s',
 			  'Integer' : '__clampd_to_int(%s)'
 			 },
 		   'GLclampf' : {
-			  'Boolean' : '(GLboolean) ( %s != 0.0f )',
+			  'Boolean' : '(GLboolean) (%s != 0.0f)',
 			  'Double'  : '(GLdouble) %s',
 			  'Float'   : '%s',
 			  'Integer' : '__clampf_to_int(%s)'
@@ -103,7 +104,7 @@ ctypes = {
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY state_get.txt AND THE state_get.py SCRIPT */
 #include <stdio.h>
 #include <math.h>
@@ -111,24 +112,24 @@ print """
 #include "state.h"
 #include "state/cr_statetypes.h"
 
-static GLint __clampd_to_int( GLdouble d )
+static GLint __clampd_to_int(GLdouble d)
 {
 	/* -1.0 -> MIN_INT, 1.0 -> MAX_INT */
-	if ( d > 1.0 )
+	if (d > 1.0)
 		return 0x7fffffff;
-	if ( d < -1.0 )
+	if (d < -1.0)
 		return 0x80000000;
-	return (GLint) floor( d * 2147483647.5 );
+	return (GLint) floor(d * 2147483647.5);
 }
 
-static GLint __clampf_to_int( GLfloat f )
+static GLint __clampf_to_int(GLfloat f)
 {
 	/* -1.0f -> MIN_INT, 1.0f -> MAX_INT */
-	if ( f > 1.0f )
+	if (f > 1.0f)
 		return 0x7fffffff;
-	if ( f < -1.0f )
+	if (f < -1.0f)
 		return 0x80000000;
-	return (GLint) floor( f * 2147483647.5f );
+	return (GLint) floor(f * 2147483647.5f);
 }
 
 static GLenum __getDrawBuffer(CRContext *g)
@@ -140,7 +141,7 @@ static GLenum __getReadBuffer(CRContext *g)
 {
     return g->framebufferobject.readFB ? g->framebufferobject.readFB->readbuffer : g->buffer.readBuffer;
 }
-"""
+""")
 
 header = """
 {
@@ -153,7 +154,7 @@ header = """
 		return;
 	}
 
-	if ( pname == GL_CURRENT_INDEX || pname == GL_CURRENT_COLOR ||
+	if (pname == GL_CURRENT_INDEX || pname == GL_CURRENT_COLOR ||
 		pname == GL_CURRENT_SECONDARY_COLOR_EXT ||
 		pname == GL_CURRENT_FOG_COORDINATE_EXT ||
 		pname == GL_CURRENT_NORMAL || pname == GL_EDGE_FLAG ||
@@ -168,41 +169,37 @@ header = """
 #endif
 	}
 
-	switch ( pname ) {
+	switch (pname) {
 """
 
 for rettype in types:
-	print ''
-	print 'void STATE_APIENTRY crStateGet%sv( GLenum pname, %s *params )' % ( rettype, ctypes[rettype] )
-	print header
-
-	keys = params.keys()
-	keys.sort()
-	for pname in keys:
-		print '\t\tcase %s:' % pname
+	print('')
+	print('void STATE_APIENTRY crStateGet%sv( GLenum pname, %s *params )' % ( rettype, ctypes[rettype] ))
+	print(header)
+
+	for pname in sorted(params.keys()):
+		print('\t\tcase %s:' % pname)
 		(srctype,fields) = params[pname]
 		try:
 			cvt = convert[srctype][rettype]
 			i = 0
 			for field in fields:
 				expr = cvt % field
-				print '\t\t\tparams[%d] = %s;' % (i,expr)
+				print('\t\t\tparams[%d] = %s;' % (i,expr))
 				i += 1
 		except:
-			print '\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");'
-		print "\t\t\tbreak;"
+			print('\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");')
+		print("\t\t\tbreak;")
 
 
-	keys = extended_params.keys();
-	keys.sort()
-	for pname in keys:
+	for pname in sorted(extended_params.keys()):
 		(srctype,ifdef,fields) = extended_params[pname]
 		ext = ifdef[3:]  # the extension name with the "GL_" prefix removed
 		#print '#ifdef %s' % ifdef
-		print '#ifdef CR_%s' % ext
-		print '\t\tcase %s:' % pname
+		print('#ifdef CR_%s' % ext)
+		print('\t\tcase %s:' % pname)
 		if ext != 'OPENGL_VERSION_1_2':
-			print '\t\t\tif (g->extensions.%s) {' % ext
+			print('\t\t\tif (g->extensions.%s) {' % ext)
 		try:
 			cvt = convert[srctype][rettype]
 			i = 0
@@ -210,28 +207,28 @@ for rettype in types:
 				expr = cvt % field
 				if field[0] == '%':
 					command = string.split(field, '%')
-					print '\t\t\t\t%s;' % command[1]
+					print('\t\t\t\t%s;' % command[1])
 					continue
 				elif ext != 'OPENGL_VERSION_1_2':
-					print '\t\t\t\tparams[%d] = %s;' % (i,expr)
+					print('\t\t\t\tparams[%d] = %s;' % (i,expr))
 				else:
-					print '\t\t\tparams[%d] = %s;' % (i,expr)
+					print('\t\t\tparams[%d] = %s;' % (i,expr))
 				i += 1
 		except:
-			print '\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");'
+			print('\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");')
 		if ext != 'OPENGL_VERSION_1_2':
-			print "\t\t\t}"
-			print "\t\t\telse {"
-			print '\t\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "glGet%sv");' % rettype
-			print "\t\t\t}"
-		print "\t\t\tbreak;"
+			print("\t\t\t}")
+			print("\t\t\telse {")
+			print('\t\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "glGet%sv");' % rettype)
+			print("\t\t\t}")
+		print("\t\t\tbreak;")
 		#print '#endif /* %s */' % ifdef
-		print '#endif /* CR_%s */' % ext
+		print('#endif /* CR_%s */' % ext)
 
-	print '\t\tdefault:'
-	print '\t\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGet: Unknown enum: 0x%x", pname);'
-	print '\t\t\treturn;'
-	print '\t}'
-	print '}'
+	print('\t\tdefault:')
+	print('\t\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGet: Unknown enum: 0x%x", pname);')
+	print('\t\t\treturn;')
+	print('\t}')
+	print('}')
 
-from get_components import *
\ No newline at end of file
+from get_components import *
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py
old mode 100644
new mode 100755
index 9ed771d..35a3815
--- a/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys, re, string
 import apiutil
 
@@ -19,7 +20,7 @@ for line in input.readlines():
 	if match:
 		type = match.group(1)
 		pname = match.group(2)
-		fields = string.split( match.group(3) )
+		fields = match.group(3).split()
 		params[pname] = ( type, fields )
 
 input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' )
@@ -29,12 +30,12 @@ for line in input.readlines():
 		type = match.group(1)
 		pname = match.group(2)
 		ifdef = match.group(3)
-		fields = string.split( match.group(4) )
+		fields = match.group(4).split()
 		extended_params[pname] = ( type, ifdef, fields )
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE GENERATED BY THE state_isenabled.py SCRIPT */
 #include <stdio.h>
 #include <math.h>
@@ -52,29 +53,23 @@ GLboolean STATE_APIENTRY crStateIsEnabled( GLenum pname )
 		return 0;
 	}
 
-    switch ( pname ) {
-"""
+    switch (pname) {
+""")
 
-keys = params.keys()
-keys.sort();
+for pname in sorted(params.keys()):
+	print("\tcase %s:" % pname)
+	print("\t\treturn %s;" % params[pname][1][0])
 
-for pname in keys:
-	print "\tcase %s:" % pname
-	print "\t\treturn %s;" % params[pname][1][0]
-
-keys = extended_params.keys();
-keys.sort()
-
-for pname in keys:
+for pname in sorted(extended_params.keys()):
 	(srctype,ifdef,fields) = extended_params[pname]
 	ext = ifdef[3:]  # the extension name with the "GL_" prefix removed
 	ext = ifdef
-	print '#ifdef CR_%s' % ext
-	print "\tcase %s:" % pname
-	print "\t\treturn %s;" % extended_params[pname][2][0]
-	print '#endif /* CR_%s */' % ext
-print "\tdefault:"
-print "\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);"
-print "\t\treturn 0;"
-print "\t}"
-print "}"
+	print('#ifdef CR_%s' % ext)
+	print("\tcase %s:" % pname)
+	print("\t\treturn %s;" % extended_params[pname][2][0])
+	print('#endif /* CR_%s */' % ext)
+print("\tdefault:")
+print("\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);")
+print("\t\treturn 0;")
+print("\t}")
+print("}")
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c
index 8cc040b..48bc6a7 100644
--- a/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c
@@ -12,7 +12,7 @@
 
 void crStateLightingInitBits (CRLightingBits *l)
 {
-	l->light = (CRLightBits *) crCalloc (sizeof(*(l->light)) * CR_MAX_LIGHTS );
+	l->light = (CRLightBits *) crCalloc (sizeof(*(l->light)) * CR_MAX_LIGHTS);
 }
 
 void crStateLightingDestroyBits (CRLightingBits *l)
@@ -22,7 +22,7 @@ void crStateLightingDestroyBits (CRLightingBits *l)
 
 void crStateLightingDestroy (CRContext *ctx)
 {
-	crFree( ctx->lighting.light );
+	crFree(ctx->lighting.light);
 }
 
 void crStateLightingInit (CRContext *ctx)
@@ -216,28 +216,28 @@ void STATE_APIENTRY crStateLightModelfv (GLenum pname, const GLfloat *param)
 			}
 			else
 			{
-				crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "LightModel: Invalid param for LIGHT_MODEL_COLOR_CONTROL: 0x%x", param[0] );
+				crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModel: Invalid param for LIGHT_MODEL_COLOR_CONTROL: 0x%x", param[0]);
 				return;
 			}
 			break;
 #else
 #if defined(CR_EXT_separate_specular_color)
 		case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:
-			if( g->extensions.EXT_separate_specular_color )
+			if(g->extensions.EXT_separate_specular_color)
 			{
-				if( param[0] == GL_SEPARATE_SPECULAR_COLOR_EXT || param[0] == GL_SINGLE_COLOR_EXT )
+				if (param[0] == GL_SEPARATE_SPECULAR_COLOR_EXT || param[0] == GL_SINGLE_COLOR_EXT)
 				{
 					l->lightModelColorControlEXT = (GLenum) param[0];
 				}
 				else
 				{
-					crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "LightModel: Invalid param for LIGHT_MODEL_COLOR_CONTROL: 0x%x", param[0] );
+					crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModel: Invalid param for LIGHT_MODEL_COLOR_CONTROL: 0x%x", param[0]);
 					return;
 				}
 			}
 			else
 			{
-				crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "LightModel( LIGHT_MODEL_COLOR_CONTROL, ...) - EXT_separate_specular_color is unavailable." );
+				crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModel( LIGHT_MODEL_COLOR_CONTROL, ...) - EXT_separate_specular_color is unavailable.");
 				return;
 			}
 			break;
@@ -264,28 +264,28 @@ void STATE_APIENTRY crStateLightModeliv (GLenum pname, const GLint *param)
 		case GL_LIGHT_MODEL_LOCAL_VIEWER:
 		case GL_LIGHT_MODEL_TWO_SIDE:
 			f_param = (GLfloat) (*param);
-			crStateLightModelfv( pname, &f_param );
+			crStateLightModelfv(pname, &f_param);
 			break;
 		case GL_LIGHT_MODEL_AMBIENT:
 			f_color.r = ((GLfloat)param[0])/CR_MAXINT;
 			f_color.g = ((GLfloat)param[1])/CR_MAXINT;
 			f_color.b = ((GLfloat)param[2])/CR_MAXINT;
 			f_color.a = ((GLfloat)param[3])/CR_MAXINT;
-			crStateLightModelfv( pname, (GLfloat *) &f_color );
+			crStateLightModelfv(pname, (GLfloat *) &f_color);
 			break;
 #if defined(CR_OPENGL_VERSION_1_2)
 		case GL_LIGHT_MODEL_COLOR_CONTROL:
 			f_param = (GLfloat) (*param);
-			crStateLightModelfv( pname, &f_param );
+			crStateLightModelfv(pname, &f_param);
 			break;
 #else
 #ifdef CR_EXT_separate_specular_color
 		case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:
-			if( g->extensions.EXT_separate_specular_color ) {
+			if (g->extensions.EXT_separate_specular_color) {
 				f_param = (GLfloat) (*param);
-				crStateLightModelfv( pname, &f_param );
+				crStateLightModelfv(pname, &f_param);
 			} else {
-				crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModeliv(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, ...) - EXT_separate_specular_color not enabled!" );
+				crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModeliv(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, ...) - EXT_separate_specular_color not enabled!");
 				return;
 			}
 			break;
@@ -299,13 +299,13 @@ void STATE_APIENTRY crStateLightModeliv (GLenum pname, const GLint *param)
 
 void STATE_APIENTRY crStateLightModelf (GLenum pname, GLfloat param)
 {
-	crStateLightModelfv( pname, &param );
+	crStateLightModelfv(pname, &param);
 }
 
 void STATE_APIENTRY crStateLightModeli (GLenum pname, GLint param)
 {
 	GLfloat f_param = (GLfloat) param;
-	crStateLightModelfv( pname, &f_param );
+	crStateLightModelfv(pname, &f_param);
 }
 
 void STATE_APIENTRY crStateLightfv (GLenum light, GLenum pname, const GLfloat *param)
@@ -469,7 +469,7 @@ void STATE_APIENTRY crStateLightiv (GLenum light, GLenum pname, const GLint *par
 			f_color.g = ((GLfloat)param[1])/CR_MAXINT;
 			f_color.b = ((GLfloat)param[2])/CR_MAXINT;
 			f_color.a = ((GLfloat)param[3])/CR_MAXINT;
-			crStateLightfv( light, pname, (GLfloat *) &f_color );
+			crStateLightfv(light, pname, (GLfloat *) &f_color);
 			break;
 		case GL_POSITION:
 		case GL_SPOT_DIRECTION:
@@ -477,7 +477,7 @@ void STATE_APIENTRY crStateLightiv (GLenum light, GLenum pname, const GLint *par
 			f_vector.y = (GLfloat) param[1];
 			f_vector.z = (GLfloat) param[2];
 			f_vector.w = (GLfloat) param[3];
-			crStateLightfv( light, pname, (GLfloat *) &f_vector );
+			crStateLightfv(light, pname, (GLfloat *) &f_vector);
 			break;
 		case GL_SPOT_EXPONENT:
 		case GL_SPOT_CUTOFF:
@@ -485,7 +485,7 @@ void STATE_APIENTRY crStateLightiv (GLenum light, GLenum pname, const GLint *par
 		case GL_LINEAR_ATTENUATION:
 		case GL_QUADRATIC_ATTENUATION:
 			f_param = (GLfloat) (*param);
-			crStateLightfv( light, pname, &f_param );
+			crStateLightfv(light, pname, &f_param);
 			break;
 		default:
 			crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLight: invalid pname: 0x%x", pname);
@@ -495,13 +495,13 @@ void STATE_APIENTRY crStateLightiv (GLenum light, GLenum pname, const GLint *par
 
 void STATE_APIENTRY crStateLightf (GLenum light, GLenum pname, GLfloat param)
 {
-	crStateLightfv( light, pname, &param );
+	crStateLightfv(light, pname, &param);
 }
 
 void STATE_APIENTRY crStateLighti (GLenum light, GLenum pname, GLint param)
 {
 	GLfloat f_param = (GLfloat) param;
-	crStateLightfv( light, pname, &f_param );
+	crStateLightfv(light, pname, &f_param);
 }
 
 void STATE_APIENTRY crStateMaterialfv (GLenum face, GLenum pname, const GLfloat *param)
@@ -718,15 +718,15 @@ void STATE_APIENTRY crStateMaterialiv (GLenum face, GLenum pname, const GLint *p
 			f_color.g = ((GLfloat) param[1]) / ((GLfloat) CR_MAXINT);
 			f_color.b = ((GLfloat) param[2]) / ((GLfloat) CR_MAXINT);
 			f_color.a = ((GLfloat) param[3]) / ((GLfloat) CR_MAXINT);
-			crStateMaterialfv( face, pname, (GLfloat *) &f_color );
+			crStateMaterialfv(face, pname, (GLfloat *) &f_color);
 			break;
 		case GL_SHININESS:
 			f_param = (GLfloat) (*param);
-			crStateMaterialfv( face, pname, (GLfloat *) &f_param );
+			crStateMaterialfv(face, pname, (GLfloat *) &f_param);
 			break;
 		case GL_COLOR_INDEXES :
 			f_param = (GLfloat) (*param);
-			crStateMaterialfv( face, pname, (GLfloat *) &f_param );
+			crStateMaterialfv(face, pname, (GLfloat *) &f_param);
 			break;
 		default:
 			crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialiv: bad pname: 0x%x", pname);
@@ -736,13 +736,13 @@ void STATE_APIENTRY crStateMaterialiv (GLenum face, GLenum pname, const GLint *p
 
 void STATE_APIENTRY crStateMaterialf (GLenum face, GLenum pname, GLfloat param)
 {
-	crStateMaterialfv( face, pname, &param );
+	crStateMaterialfv(face, pname, &param);
 }
 
 void STATE_APIENTRY crStateMateriali (GLenum face, GLenum pname, GLint param)
 {
 	GLfloat f_param = (GLfloat) param;
-	crStateMaterialfv( face, pname, &f_param );
+	crStateMaterialfv(face, pname, &f_param);
 }
 
 void STATE_APIENTRY crStateGetLightfv (GLenum light, GLenum pname, GLfloat *param)
@@ -1207,6 +1207,6 @@ void crStateColorMaterialRecover(void)
 		 */
 		crStateFlushFunc(NULL);
 
-		crStateMaterialfv( l->colorMaterialFace, l->colorMaterialMode, &(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]) );
+		crStateMaterialfv(l->colorMaterialFace, l->colorMaterialMode, &(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]));
 	}
 }
diff --git a/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py b/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py
old mode 100644
new mode 100755
index 3312d23..cf07424
--- a/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py
+++ b/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py
@@ -3,8 +3,8 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys;
-import cPickle;
 import string;
 import re;
 
@@ -12,31 +12,31 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 #include "cr_debugopcodes.h"
 #include <stdio.h>
-"""
+""")
 
-print """void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes )
+print("""void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes )
 {
 \tunsigned int i;
-\tfor (i = 0 ; i < num_opcodes ; i++)
+\tfor (i = 0; i < num_opcodes; i++)
 \t{
 \t\tswitch(*(ptr--))
 \t\t{
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 keys.sort()
 
 for func_name in keys:
 	if "pack" in apiutil.ChromiumProps(func_name):
-		print '\t\tcase %s:' % apiutil.OpcodeName( func_name )
-		print '\t\t\tfprintf( fp, "%s\\n" ); ' % apiutil.OpcodeName( func_name )
-		print '\t\t\tbreak;'
+		print('\t\tcase %s:' % apiutil.OpcodeName( func_name ))
+		print('\t\t\tfprintf(fp, "%s\\n"); ' % apiutil.OpcodeName( func_name ))
+		print( '\t\t\tbreak;')
 
-print """
+print("""
 \t\t}
 \t}
 }
-"""
+""")
diff --git a/src/VBox/HostDrivers/Support/SUPDrvGip.cpp b/src/VBox/HostDrivers/Support/SUPDrvGip.cpp
index e826a35..ca9aa4d 100644
--- a/src/VBox/HostDrivers/Support/SUPDrvGip.cpp
+++ b/src/VBox/HostDrivers/Support/SUPDrvGip.cpp
@@ -273,6 +273,8 @@ static DECLCALLBACK(void) supdrvGipDetectGetGipCpuCallback(RTCPUID idCpu, void *
             && iCpuSet < RTCPUSET_MAX_CPUS
             && RT_IS_POWER_OF_TWO(RTCPUSET_MAX_CPUS))
         {
+            PSUPGIPCPU pGipCpu = SUPGetGipCpuBySetIndex(pGip, iCpuSet);
+
             /*
              * Check whether the IDTR.LIMIT contains a CPU number.
              */
@@ -304,7 +306,7 @@ static DECLCALLBACK(void) supdrvGipDetectGetGipCpuCallback(RTCPUID idCpu, void *
                 if (   ASMIsValidExtRange(ASMCpuId_EAX(UINT32_C(0x80000000)))
                     && (ASMCpuId_EDX(UINT32_C(0x80000001)) & X86_CPUID_EXT_FEATURE_EDX_RDTSCP) )
                 {
-                    uint32_t uAux;
+                    uint32_t        uAux;
                     ASMReadTscWithAux(&uAux);
                     if ((uAux & (RTCPUSET_MAX_CPUS - 1)) == idCpu)
                     {
@@ -313,6 +315,19 @@ static DECLCALLBACK(void) supdrvGipDetectGetGipCpuCallback(RTCPUID idCpu, void *
                         if ((uAux & (RTCPUSET_MAX_CPUS - 1)) == idCpu)
                             fSupported |= SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS;
                     }
+
+                    if (pGipCpu)
+                    {
+                        uint32_t const  uGroupedAux = (uint8_t)pGipCpu->iCpuGroupMember | ((uint32_t)pGipCpu->iCpuGroup << 8);
+                        if (   (uAux & UINT16_MAX) == uGroupedAux
+                            && pGipCpu->iCpuGroupMember <= UINT8_MAX)
+                        {
+                            ASMNopPause();
+                            ASMReadTscWithAux(&uAux);
+                            if ((uAux & UINT16_MAX) == uGroupedAux)
+                                fSupported |= SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL;
+                        }
+                    }
                 }
             }
         }
@@ -1258,11 +1273,11 @@ static uint32_t supdrvGipFindOrAllocCpuIndexForCpuId(PSUPGLOBALINFOPAGE pGip, RT
  */
 static void supdrvGipMpEventOnlineOrInitOnCpu(PSUPDRVDEVEXT pDevExt, RTCPUID idCpu)
 {
-    int         iCpuSet = 0;
-    uint16_t    idApic = UINT16_MAX;
-    uint32_t    i = 0;
-    uint64_t    u64NanoTS = 0;
-    PSUPGLOBALINFOPAGE pGip = pDevExt->pGip;
+    PSUPGLOBALINFOPAGE  pGip      = pDevExt->pGip;
+    int                 iCpuSet   = 0;
+    uint16_t            idApic    = UINT16_MAX;
+    uint32_t            i         = 0;
+    uint64_t            u64NanoTS = 0;
 
     AssertPtrReturnVoid(pGip);
     Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
@@ -1301,6 +1316,12 @@ static void supdrvGipMpEventOnlineOrInitOnCpu(PSUPDRVDEVEXT pDevExt, RTCPUID idC
     ASMAtomicWriteS16(&pGip->aCPUs[i].iCpuSet, (int16_t)iCpuSet);
     ASMAtomicWriteSize(&pGip->aCPUs[i].idCpu,  idCpu);
 
+    pGip->aCPUs[i].iCpuGroup = 0;
+    pGip->aCPUs[i].iCpuGroupMember = iCpuSet;
+#ifdef RT_OS_WINDOWS
+    supdrvOSGipInitGroupBitsForCpu(pDevExt, pGip, &pGip->aCPUs[i]);
+#endif
+
     /*
      * Update the APIC ID and CPU set index mappings.
      */
@@ -1682,10 +1703,13 @@ static void supdrvGipInitCpu(PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pCpu, uint64_t
     pCpu->u64TSCSample       = GIP_TSC_DELTA_RSVD;
     pCpu->i64TSCDelta        = pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED ? INT64_MAX : 0;
 
-    ASMAtomicWriteSize(&pCpu->enmState, SUPGIPCPUSTATE_INVALID);
-    ASMAtomicWriteU32(&pCpu->idCpu,     NIL_RTCPUID);
-    ASMAtomicWriteS16(&pCpu->iCpuSet,   -1);
-    ASMAtomicWriteU16(&pCpu->idApic,    UINT16_MAX);
+    ASMAtomicWriteSize(&pCpu->enmState,             SUPGIPCPUSTATE_INVALID);
+    ASMAtomicWriteU32(&pCpu->idCpu,                 NIL_RTCPUID);
+    ASMAtomicWriteS16(&pCpu->iCpuSet,               -1);
+    ASMAtomicWriteU16(&pCpu->iCpuGroup,             0);
+    ASMAtomicWriteU16(&pCpu->iCpuGroupMember,       UINT16_MAX);
+    ASMAtomicWriteU16(&pCpu->idApic,                UINT16_MAX);
+    ASMAtomicWriteU32(&pCpu->iReservedForNumaNode,  0);
 
     /*
      * The first time we're called, we don't have a CPU frequency handy,
@@ -1719,6 +1743,7 @@ static void supdrvGipInitCpu(PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pCpu, uint64_t
 /**
  * Initializes the GIP data.
  *
+ * @returns VBox status code.
  * @param   pDevExt             Pointer to the device instance data.
  * @param   pGip                Pointer to the read-write kernel mapping of the GIP.
  * @param   HCPhys              The physical address of the GIP.
@@ -1726,12 +1751,15 @@ static void supdrvGipInitCpu(PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pCpu, uint64_t
  * @param   uUpdateHz           The update frequency.
  * @param   uUpdateIntervalNS   The update interval in nanoseconds.
  * @param   cCpus               The CPU count.
+ * @param   cbGipCpuGroups      The supdrvOSGipGetGroupTableSize return value we
+ *                              used when allocating the GIP structure.
  */
-static void supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys,
-                          uint64_t u64NanoTS, unsigned uUpdateHz, unsigned uUpdateIntervalNS, unsigned cCpus)
+static int supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys,
+                         uint64_t u64NanoTS, unsigned uUpdateHz, unsigned uUpdateIntervalNS,
+                         unsigned cCpus, size_t cbGipCpuGroups)
 {
-    size_t const    cbGip = RT_ALIGN_Z(RT_OFFSETOF(SUPGLOBALINFOPAGE, aCPUs[cCpus]), PAGE_SIZE);
-    unsigned        i;
+    size_t const cbGip = RT_ALIGN_Z(RT_OFFSETOF(SUPGLOBALINFOPAGE, aCPUs[cCpus]) + cbGipCpuGroups, PAGE_SIZE);
+    unsigned i;
 #ifdef DEBUG_DARWIN_GIP
     OSDBGPRINT(("supdrvGipInit: pGip=%p HCPhys=%lx u64NanoTS=%llu uUpdateHz=%d cCpus=%u\n", pGip, (long)HCPhys, u64NanoTS, uUpdateHz, cCpus));
 #else
@@ -1763,13 +1791,20 @@ static void supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPH
     pGip->cOnlineCpus             = RTMpGetOnlineCount();
     pGip->cPresentCpus            = RTMpGetPresentCount();
     pGip->cPossibleCpus           = RTMpGetCount();
+    pGip->cPossibleCpuGroups      = 1;
     pGip->idCpuMax                = RTMpGetMaxCpuId();
     for (i = 0; i < RT_ELEMENTS(pGip->aiCpuFromApicId); i++)
         pGip->aiCpuFromApicId[i]    = UINT16_MAX;
     for (i = 0; i < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx); i++)
         pGip->aiCpuFromCpuSetIdx[i] = UINT16_MAX;
+    for (i = 0; i < RT_ELEMENTS(pGip->aoffCpuGroup); i++)
+        pGip->aoffCpuGroup[i] = UINT16_MAX;
     for (i = 0; i < cCpus; i++)
         supdrvGipInitCpu(pGip, &pGip->aCPUs[i], u64NanoTS, 0 /*uCpuHz*/);
+#ifdef RT_OS_WINDOWS
+    int rc = supdrvOSInitGipGroupTable(pDevExt, pGip, cbGipCpuGroups);
+    AssertRCReturn(rc, rc);
+#endif
 
     /*
      * Link it to the device extension.
@@ -1777,6 +1812,8 @@ static void supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPH
     pDevExt->pGip      = pGip;
     pDevExt->HCPhysGip = HCPhys;
     pDevExt->cGipUsers = 0;
+
+    return VINF_SUCCESS;
 }
 
 
@@ -1789,6 +1826,8 @@ static void supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPH
 int VBOXCALL supdrvGipCreate(PSUPDRVDEVEXT pDevExt)
 {
     PSUPGLOBALINFOPAGE  pGip;
+    size_t              cbGip;
+    size_t              cbGipCpuGroups;
     RTHCPHYS            HCPhysGip;
     uint32_t            u32SystemResolution;
     uint32_t            u32Interval;
@@ -1830,7 +1869,13 @@ int VBOXCALL supdrvGipCreate(PSUPDRVDEVEXT pDevExt)
     /*
      * Allocate a contiguous set of pages with a default kernel mapping.
      */
-    rc = RTR0MemObjAllocCont(&pDevExt->GipMemObj, RT_UOFFSETOF(SUPGLOBALINFOPAGE, aCPUs[cCpus]), false /*fExecutable*/);
+#ifdef RT_OS_WINDOWS
+    cbGipCpuGroups = supdrvOSGipGetGroupTableSize(pDevExt);
+#else
+    cbGipCpuGroups = 0;
+#endif
+    cbGip = RT_UOFFSETOF(SUPGLOBALINFOPAGE, aCPUs[cCpus]) + cbGipCpuGroups;
+    rc = RTR0MemObjAllocCont(&pDevExt->GipMemObj, cbGip, false /*fExecutable*/);
     if (RT_FAILURE(rc))
     {
         OSDBGPRINT(("supdrvGipCreate: failed to allocate the GIP page. rc=%d\n", rc));
@@ -1852,22 +1897,24 @@ int VBOXCALL supdrvGipCreate(PSUPDRVDEVEXT pDevExt)
     if (uMod)
         u32Interval += u32SystemResolution - uMod;
 
-    supdrvGipInit(pDevExt, pGip, HCPhysGip, RTTimeSystemNanoTS(), RT_NS_1SEC / u32Interval /*=Hz*/, u32Interval, cCpus);
+    rc = supdrvGipInit(pDevExt, pGip, HCPhysGip, RTTimeSystemNanoTS(), RT_NS_1SEC / u32Interval /*=Hz*/, u32Interval,
+                       cCpus, cbGipCpuGroups);
 
     /*
-     * Important sanity check...
+     * Important sanity check...  (Sets rc)
      */
     if (RT_UNLIKELY(   pGip->enmUseTscDelta == SUPGIPUSETSCDELTA_ZERO_CLAIMED
                     && pGip->u32Mode == SUPGIPMODE_ASYNC_TSC
                     && !supdrvOSGetForcedAsyncTscMode(pDevExt)))
     {
         OSDBGPRINT(("supdrvGipCreate: Host-OS/user claims the TSC-deltas are zero but we detected async. TSC! Bad.\n"));
-        return VERR_INTERNAL_ERROR_2;
+        rc = VERR_INTERNAL_ERROR_2;
     }
 
     /* It doesn't make sense to do TSC-delta detection on systems we detect as async. */
-    AssertReturn(   pGip->u32Mode != SUPGIPMODE_ASYNC_TSC
-                 || pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ZERO_CLAIMED, VERR_INTERNAL_ERROR_3);
+    AssertStmt(   pGip->u32Mode != SUPGIPMODE_ASYNC_TSC
+               || pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ZERO_CLAIMED,
+               rc = VERR_INTERNAL_ERROR_3);
 
     /*
      * Do the TSC frequency measurements.
@@ -1880,107 +1927,112 @@ int VBOXCALL supdrvGipCreate(PSUPDRVDEVEXT pDevExt)
      * that supdrvGipInitOnCpu() can populate the TSC interval and history
      * array with more reasonable values.
      */
-    if (pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC)
-    {
-        rc = supdrvGipInitMeasureTscFreq(pGip, true /*fRough*/); /* cannot fail */
-        supdrvGipInitStartTimerForRefiningInvariantTscFreq(pDevExt);
-    }
-    else
-        rc = supdrvGipInitMeasureTscFreq(pGip, false /*fRough*/);
     if (RT_SUCCESS(rc))
     {
-        /*
-         * Start TSC-delta measurement thread before we start getting MP
-         * events that will try kick it into action (includes the
-         * RTMpOnAll/supdrvGipInitOnCpu call below).
-         */
-        RTCpuSetEmpty(&pDevExt->TscDeltaCpuSet);
-        RTCpuSetEmpty(&pDevExt->TscDeltaObtainedCpuSet);
-#ifdef SUPDRV_USE_TSC_DELTA_THREAD
-        if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED)
-            rc = supdrvTscDeltaThreadInit(pDevExt);
-#endif
+        if (pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC)
+        {
+            rc = supdrvGipInitMeasureTscFreq(pGip, true /*fRough*/); /* cannot fail */
+            supdrvGipInitStartTimerForRefiningInvariantTscFreq(pDevExt);
+        }
+        else
+            rc = supdrvGipInitMeasureTscFreq(pGip, false /*fRough*/);
         if (RT_SUCCESS(rc))
         {
-            rc = RTMpNotificationRegister(supdrvGipMpEvent, pDevExt);
+            /*
+             * Start TSC-delta measurement thread before we start getting MP
+             * events that will try kick it into action (includes the
+             * RTMpOnAll/supdrvGipInitOnCpu call below).
+             */
+            RTCpuSetEmpty(&pDevExt->TscDeltaCpuSet);
+            RTCpuSetEmpty(&pDevExt->TscDeltaObtainedCpuSet);
+#ifdef SUPDRV_USE_TSC_DELTA_THREAD
+            if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED)
+                rc = supdrvTscDeltaThreadInit(pDevExt);
+#endif
             if (RT_SUCCESS(rc))
             {
-                /*
-                 * Do GIP initialization on all online CPUs.  Wake up the
-                 * TSC-delta thread afterwards.
-                 */
-                rc = RTMpOnAll(supdrvGipInitOnCpu, pDevExt, pGip);
+                rc = RTMpNotificationRegister(supdrvGipMpEvent, pDevExt);
                 if (RT_SUCCESS(rc))
                 {
-#ifdef SUPDRV_USE_TSC_DELTA_THREAD
-                    supdrvTscDeltaThreadStartMeasurement(pDevExt, true /* fForceAll */);
-#else
-                    uint16_t iCpu;
-                    if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED)
-                    {
-                        /*
-                         * Measure the TSC deltas now that we have MP notifications.
-                         */
-                        int cTries = 5;
-                        do
-                        {
-                            rc = supdrvMeasureInitialTscDeltas(pDevExt);
-                            if (   rc != VERR_TRY_AGAIN
-                                && rc != VERR_CPU_OFFLINE)
-                                break;
-                        } while (--cTries > 0);
-                        for (iCpu = 0; iCpu < pGip->cCpus; iCpu++)
-                            Log(("supdrvTscDeltaInit: cpu[%u] delta %lld\n", iCpu, pGip->aCPUs[iCpu].i64TSCDelta));
-                    }
-                    else
-                    {
-                        for (iCpu = 0; iCpu < pGip->cCpus; iCpu++)
-                            AssertMsg(!pGip->aCPUs[iCpu].i64TSCDelta, ("iCpu=%u %lld mode=%d\n", iCpu, pGip->aCPUs[iCpu].i64TSCDelta, pGip->u32Mode));
-                    }
+                    /*
+                     * Do GIP initialization on all online CPUs.  Wake up the
+                     * TSC-delta thread afterwards.
+                     */
+                    rc = RTMpOnAll(supdrvGipInitOnCpu, pDevExt, pGip);
                     if (RT_SUCCESS(rc))
-#endif
                     {
-                        /*
-                         * Create the timer.
-                         * If CPU_ALL isn't supported we'll have to fall back to synchronous mode.
-                         */
-                        if (pGip->u32Mode == SUPGIPMODE_ASYNC_TSC)
+#ifdef SUPDRV_USE_TSC_DELTA_THREAD
+                        supdrvTscDeltaThreadStartMeasurement(pDevExt, true /* fForceAll */);
+#else
+                        uint16_t iCpu;
+                        if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED)
                         {
-                            rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, RTTIMER_FLAGS_CPU_ALL,
-                                                 supdrvGipAsyncTimer, pDevExt);
-                            if (rc == VERR_NOT_SUPPORTED)
+                            /*
+                             * Measure the TSC deltas now that we have MP notifications.
+                             */
+                            int cTries = 5;
+                            do
                             {
-                                OSDBGPRINT(("supdrvGipCreate: omni timer not supported, falling back to synchronous mode\n"));
-                                pGip->u32Mode = SUPGIPMODE_SYNC_TSC;
-                            }
+                                rc = supdrvMeasureInitialTscDeltas(pDevExt);
+                                if (   rc != VERR_TRY_AGAIN
+                                    && rc != VERR_CPU_OFFLINE)
+                                    break;
+                            } while (--cTries > 0);
+                            for (iCpu = 0; iCpu < pGip->cCpus; iCpu++)
+                                Log(("supdrvTscDeltaInit: cpu[%u] delta %lld\n", iCpu, pGip->aCPUs[iCpu].i64TSCDelta));
+                        }
+                        else
+                        {
+                            for (iCpu = 0; iCpu < pGip->cCpus; iCpu++)
+                                AssertMsg(!pGip->aCPUs[iCpu].i64TSCDelta, ("iCpu=%u %lld mode=%d\n", iCpu, pGip->aCPUs[iCpu].i64TSCDelta, pGip->u32Mode));
                         }
-                        if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
-                            rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, 0 /* fFlags */,
-                                                 supdrvGipSyncAndInvariantTimer, pDevExt);
                         if (RT_SUCCESS(rc))
+#endif
                         {
                             /*
-                             * We're good.
+                             * Create the timer.
+                             * If CPU_ALL isn't supported we'll have to fall back to synchronous mode.
                              */
-                            Log(("supdrvGipCreate: %u ns interval.\n", u32Interval));
-                            supdrvGipReleaseHigherTimerFrequencyFromSystem(pDevExt);
+                            if (pGip->u32Mode == SUPGIPMODE_ASYNC_TSC)
+                            {
+                                rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, RTTIMER_FLAGS_CPU_ALL,
+                                                     supdrvGipAsyncTimer, pDevExt);
+                                if (rc == VERR_NOT_SUPPORTED)
+                                {
+                                    OSDBGPRINT(("supdrvGipCreate: omni timer not supported, falling back to synchronous mode\n"));
+                                    pGip->u32Mode = SUPGIPMODE_SYNC_TSC;
+                                }
+                            }
+                            if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
+                                rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, 0 /* fFlags */,
+                                                     supdrvGipSyncAndInvariantTimer, pDevExt);
+                            if (RT_SUCCESS(rc))
+                            {
+                                /*
+                                 * We're good.
+                                 */
+                                Log(("supdrvGipCreate: %u ns interval.\n", u32Interval));
+                                supdrvGipReleaseHigherTimerFrequencyFromSystem(pDevExt);
 
-                            g_pSUPGlobalInfoPage = pGip;
-                            return VINF_SUCCESS;
-                        }
+                                g_pSUPGlobalInfoPage = pGip;
+                                return VINF_SUCCESS;
+                            }
 
-                        OSDBGPRINT(("supdrvGipCreate: failed create GIP timer at %u ns interval. rc=%Rrc\n", u32Interval, rc));
-                        Assert(!pDevExt->pGipTimer);
+                            OSDBGPRINT(("supdrvGipCreate: failed create GIP timer at %u ns interval. rc=%Rrc\n", u32Interval, rc));
+                            Assert(!pDevExt->pGipTimer);
+                        }
                     }
+                    else
+                        OSDBGPRINT(("supdrvGipCreate: RTMpOnAll failed. rc=%Rrc\n", rc));
                 }
                 else
-                    OSDBGPRINT(("supdrvGipCreate: RTMpOnAll failed. rc=%Rrc\n", rc));
+                    OSDBGPRINT(("supdrvGipCreate: failed to register MP event notfication. rc=%Rrc\n", rc));
             }
             else
-                OSDBGPRINT(("supdrvGipCreate: failed to register MP event notfication. rc=%Rrc\n", rc));
+                OSDBGPRINT(("supdrvGipCreate: supdrvTscDeltaInit failed. rc=%Rrc\n", rc));
         }
         else
-            OSDBGPRINT(("supdrvGipCreate: supdrvTscDeltaInit failed. rc=%Rrc\n", rc));
+            OSDBGPRINT(("supdrvGipCreate: supdrvTscMeasureInitialDeltas failed. rc=%Rrc\n", rc));
     }
     else
         OSDBGPRINT(("supdrvGipCreate: supdrvMeasureInitialTscDeltas failed. rc=%Rrc\n", rc));
@@ -2393,7 +2445,9 @@ static void supdrvGipUpdatePerCpu(PSUPDRVDEVEXT pDevExt, uint64_t u64NanoTS, uin
      * the onlined CPU but the tick creeps in before the event notification is
      * run.
      */
-    if (RT_UNLIKELY(iTick == 1))
+    if (RT_LIKELY(iTick != 1))
+    { /* likely*/ }
+    else
     {
         iCpu = supdrvGipFindOrAllocCpuIndexForCpuId(pGip, idCpu);
         if (pGip->aCPUs[iCpu].enmState == SUPGIPCPUSTATE_OFFLINE)
diff --git a/src/VBox/HostDrivers/Support/SUPDrvIOC.h b/src/VBox/HostDrivers/Support/SUPDrvIOC.h
index a0b352e..1d176a6 100644
--- a/src/VBox/HostDrivers/Support/SUPDrvIOC.h
+++ b/src/VBox/HostDrivers/Support/SUPDrvIOC.h
@@ -214,7 +214,7 @@ typedef SUPREQHDR *PSUPREQHDR;
  * @todo Pending work on next major version change:
  *          - nothing.
  */
-#define SUPDRV_IOC_VERSION                              0x00260000
+#define SUPDRV_IOC_VERSION                              0x00280000
 
 /** SUP_IOCTL_COOKIE. */
 typedef struct SUPCOOKIE
diff --git a/src/VBox/HostDrivers/Support/SUPDrvInternal.h b/src/VBox/HostDrivers/Support/SUPDrvInternal.h
index c6e6611..aadaa71 100644
--- a/src/VBox/HostDrivers/Support/SUPDrvInternal.h
+++ b/src/VBox/HostDrivers/Support/SUPDrvInternal.h
@@ -799,6 +799,42 @@ void VBOXCALL   supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSES
  */
 void VBOXCALL   supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
 
+/**
+ * Called during GIP initializtion to calc the CPU group table size.
+ *
+ * This is currently only implemented on windows [lazy bird].
+ *
+ * @returns Number of bytes needed for SUPGIPCPUGROUP structures.
+ * @param   pDevExt             The device globals.
+ */
+size_t VBOXCALL supdrvOSGipGetGroupTableSize(PSUPDRVDEVEXT pDevExt);
+
+/**
+ * Called during GIP initialization to set up the group table and group count.
+ *
+ * This is currently only implemented on windows [lazy bird].
+ *
+ * @param   pDevExt             The device globals.
+ * @param   pGip                The GIP which group table needs initialization.
+ *                              It's only partially initialized at this point.
+ * @param   cbGipCpuGroups      What supdrvOSGipGetGroupTableSize returned.
+ */
+int VBOXCALL    supdrvOSInitGipGroupTable(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, size_t cbGipCpuGroups);
+
+/**
+ * Initializes the group related members when a CPU is added to the GIP.
+ *
+ * This is called both during GIP initalization and during an CPU online event.
+ *
+ * This is currently only implemented on windows [lazy bird].
+ *
+ * @returns CPU group number.
+ * @param   pDevExt             The device globals.
+ * @param   pGip                The GIP.
+ * @param   pGipCpu             The GIP CPU structure being initialized.
+ */
+void VBOXCALL supdrvOSGipInitGroupBitsForCpu(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pGipCpu);
+
 void VBOXCALL   supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
 bool VBOXCALL   supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
 bool VBOXCALL   supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt);
diff --git a/src/VBox/HostDrivers/Support/SUPLib.cpp b/src/VBox/HostDrivers/Support/SUPLib.cpp
index 1ad88ad..fc5f623 100644
--- a/src/VBox/HostDrivers/Support/SUPLib.cpp
+++ b/src/VBox/HostDrivers/Support/SUPLib.cpp
@@ -1111,6 +1111,13 @@ SUPR3DECL(int) SUPR3PageAllocEx(size_t cPages, uint32_t fFlags, void **ppvPages,
         return VINF_SUCCESS;
     }
 
+    /* Check that we've got a kernel connection so rtMemSaferSupR3AllocPages
+       can do fallback without first having to hit assertions. */
+    if (g_supLibData.hDevice != SUP_HDEVICE_NIL)
+    { /* likely */ }
+    else
+        return VERR_WRONG_ORDER;
+
     /*
      * Use fallback for non-R0 mapping?
      */
diff --git a/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp b/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp
index 7374821..d4fb5f5 100644
--- a/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp
+++ b/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp
@@ -130,17 +130,34 @@ extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv)
                 && g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_INVARIANT_TSC)
                 SUPR3GipSetFlags(SUPGIP_FLAGS_TESTING_ENABLE, UINT32_MAX);
 
-            RTPrintf("tstGIP-2: cCpus=%d  u32UpdateHz=%RU32  u32UpdateIntervalNS=%RU32  u64NanoTSLastUpdateHz=%RX64  u64CpuHz=%RU64  uCpuHzRef=%RU64  u32Mode=%d (%s)  fTestMode=%RTbool  u32Version=%#x\n",
+            RTPrintf("tstGIP-2: u32Mode=%d (%s)  fTestMode=%RTbool  u32Version=%#x  fGetGipCpu=%#RX32\n",
+                     g_pSUPGlobalInfoPage->u32Mode,
+                     SUPGetGIPModeName(g_pSUPGlobalInfoPage),
+                     fTestMode,
+                     g_pSUPGlobalInfoPage->u32Version,
+                     g_pSUPGlobalInfoPage->fGetGipCpu);
+            RTPrintf("tstGIP-2: cCpus=%d  cPossibleCpus=%d cPossibleCpuGroups=%d cPresentCpus=%d cOnlineCpus=%d idCpuMax=%#x\n",
                      g_pSUPGlobalInfoPage->cCpus,
+                     g_pSUPGlobalInfoPage->cPossibleCpus,
+                     g_pSUPGlobalInfoPage->cPossibleCpuGroups,
+                     g_pSUPGlobalInfoPage->cPresentCpus,
+                     g_pSUPGlobalInfoPage->cOnlineCpus,
+                     g_pSUPGlobalInfoPage->idCpuMax);
+            RTPrintf("tstGIP-2: u32UpdateHz=%RU32  u32UpdateIntervalNS=%RU32  u64NanoTSLastUpdateHz=%RX64  u64CpuHz=%RU64  uCpuHzRef=%RU64\n",
                      g_pSUPGlobalInfoPage->u32UpdateHz,
                      g_pSUPGlobalInfoPage->u32UpdateIntervalNS,
                      g_pSUPGlobalInfoPage->u64NanoTSLastUpdateHz,
                      g_pSUPGlobalInfoPage->u64CpuHz,
-                     uCpuHzRef,
-                     g_pSUPGlobalInfoPage->u32Mode,
-                     SUPGetGIPModeName(g_pSUPGlobalInfoPage),
-                     fTestMode,
-                     g_pSUPGlobalInfoPage->u32Version);
+                     uCpuHzRef);
+            for (uint32_t iCpu = 0; iCpu < g_pSUPGlobalInfoPage->cCpus; iCpu++)
+                if (g_pSUPGlobalInfoPage->aCPUs[iCpu].enmState != SUPGIPCPUSTATE_INVALID)
+                {
+                    SUPGIPCPU const *pGipCpu = &g_pSUPGlobalInfoPage->aCPUs[iCpu];
+                    RTPrintf("tstGIP-2: aCPU[%u]: enmState=%d iCpuSet=%u idCpu=%#010x iCpuGroup=%u iCpuGroupMember=%u idApic=%#x\n",
+                             iCpu, pGipCpu->enmState, pGipCpu->iCpuSet, pGipCpu->idCpu, pGipCpu->iCpuGroup,
+                             pGipCpu->iCpuGroupMember, pGipCpu->idApic);
+                }
+
             RTPrintf(fHex
                      ? "tstGIP-2:     it: u64NanoTS        delta     u64TSC           UpIntTSC H  TransId      CpuHz      %sTSC Interval History...\n"
                      : "tstGIP-2:     it: u64NanoTS        delta     u64TSC             UpIntTSC H    TransId      CpuHz      %sTSC Interval History...\n",
diff --git a/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp b/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
index 8f1e23e..aba213f 100644
--- a/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
+++ b/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
@@ -358,6 +358,40 @@ static FAST_IO_DISPATCH const g_VBoxDrvFastIoDispatch =
 };
 #endif /* VBOXDRV_WITH_FAST_IO */
 
+/** Default ZERO value. */
+static ULONG                        g_fOptDefaultZero = 0;
+/** Registry values.
+ * We wrap these in a struct to ensure they are followed by a little zero
+ * padding in order to limit the chance of trouble on unpatched systems.  */
+struct
+{
+    /** The ForceAsync registry value. */
+    ULONG                           fOptForceAsyncTsc;
+    /** Padding. */
+    uint64_t                        au64Padding[2];
+}                                   g_Options = { FALSE, 0, 0 };
+/** Registry query table for RtlQueryRegistryValues. */
+static RTL_QUERY_REGISTRY_TABLE     g_aRegValues[] =
+{
+    {
+        /* .QueryRoutine = */   NULL,
+        /* .Flags = */          RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_TYPECHECK,
+        /* .Name = */           L"ForceAsyncTsc",
+        /* .EntryContext = */   &g_Options.fOptForceAsyncTsc,
+        /* .DefaultType = */    (REG_DWORD << RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) | REG_DWORD,
+        /* .DefaultData = */    &g_fOptDefaultZero,
+        /* .DefaultLength = */  sizeof(g_fOptDefaultZero),
+    },
+    {   NULL, 0, NULL, NULL, 0, NULL, 0 } /* terminator entry. */
+};
+
+/** Pointer to KeQueryMaximumGroupCount. */
+static PFNKEQUERYMAXIMUMGROUPCOUNT      g_pfnKeQueryMaximumGroupCount = NULL;
+/** Pointer to KeGetProcessorIndexFromNumber. */
+static PFNKEGETPROCESSORINDEXFROMNUMBER g_pfnKeGetProcessorIndexFromNumber = NULL;
+/** Pointer to KeGetProcessorNumberFromIndex. */
+static PFNKEGETPROCESSORNUMBERFROMINDEX g_pfnKeGetProcessorNumberFromIndex = NULL;
+
 #ifdef VBOX_WITH_HARDENING
 /** Pointer to the stub device instance. */
 static PDEVICE_OBJECT               g_pDevObjStub = NULL;
@@ -553,9 +587,43 @@ NTSTATUS _stdcall DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath)
 #endif
 
     /*
-     * Initialize the runtime (IPRT).
+     * Query options first so any overflows on unpatched machines will do less
+     * harm (see MS11-011 / 2393802 / 2011-03-18).
+     *
+     * Unfortunately, pRegPath isn't documented as zero terminated, even if it
+     * quite likely always is, so we have to make a copy here.
      */
     NTSTATUS rcNt;
+    PWSTR pwszCopy = (PWSTR)ExAllocatePoolWithTag(NonPagedPool, pRegPath->Length + sizeof(WCHAR), 'VBox');
+    if (pwszCopy)
+    {
+        memcpy(pwszCopy, pRegPath->Buffer, pRegPath->Length);
+        pwszCopy[pRegPath->Length / sizeof(WCHAR)] = '\0';
+        rcNt = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pwszCopy,
+                                      g_aRegValues, NULL /*pvContext*/, NULL /*pvEnv*/);
+        ExFreePoolWithTag(pwszCopy, 'VBox');
+        /* Probably safe to ignore rcNt here. */
+    }
+
+    /*
+     * Resolve methods we want but isn't available everywhere.
+     */
+    UNICODE_STRING RoutineName;
+    RtlInitUnicodeString(&RoutineName, L"KeQueryMaximumGroupCount");
+    g_pfnKeQueryMaximumGroupCount = (PFNKEQUERYMAXIMUMGROUPCOUNT)MmGetSystemRoutineAddress(&RoutineName);
+
+    RtlInitUnicodeString(&RoutineName, L"KeGetProcessorIndexFromNumber");
+    g_pfnKeGetProcessorIndexFromNumber = (PFNKEGETPROCESSORINDEXFROMNUMBER)MmGetSystemRoutineAddress(&RoutineName);
+
+    RtlInitUnicodeString(&RoutineName, L"KeGetProcessorNumberFromIndex");
+    g_pfnKeGetProcessorNumberFromIndex = (PFNKEGETPROCESSORNUMBERFROMINDEX)MmGetSystemRoutineAddress(&RoutineName);
+
+    Assert(   (g_pfnKeGetProcessorNumberFromIndex != NULL) == (g_pfnKeGetProcessorIndexFromNumber != NULL)
+           && (g_pfnKeGetProcessorNumberFromIndex != NULL) == (g_pfnKeQueryMaximumGroupCount != NULL)); /* all or nothing. */
+
+    /*
+     * Initialize the runtime (IPRT).
+     */
     int vrc = RTR0Init(0);
     if (RT_SUCCESS(vrc))
     {
@@ -1642,6 +1710,103 @@ void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSIO
 }
 
 
+size_t VBOXCALL supdrvOSGipGetGroupTableSize(PSUPDRVDEVEXT pDevExt)
+{
+    NOREF(pDevExt);
+    uint32_t cMaxCpus = RTMpGetCount();
+    uint32_t cGroups  = RTMpGetMaxCpuGroupCount();
+
+    return cGroups * RT_OFFSETOF(SUPGIPCPUGROUP, aiCpuSetIdxs)
+         + RT_SIZEOFMEMB(SUPGIPCPUGROUP, aiCpuSetIdxs[0]) * cMaxCpus;
+}
+
+
+int VBOXCALL supdrvOSInitGipGroupTable(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, size_t cbGipCpuGroups)
+{
+    Assert(cbGipCpuGroups > 0); NOREF(cbGipCpuGroups); NOREF(pDevExt);
+
+    unsigned const  cGroups = RTMpGetMaxCpuGroupCount();
+    AssertReturn(cGroups > 0 && cGroups < RT_ELEMENTS(pGip->aoffCpuGroup), VERR_INTERNAL_ERROR_2);
+    pGip->cPossibleCpuGroups = cGroups;
+
+    PSUPGIPCPUGROUP pGroup = (PSUPGIPCPUGROUP)&pGip->aCPUs[pGip->cCpus];
+    for (uint32_t idxGroup = 0; idxGroup < cGroups; idxGroup++)
+    {
+        uint32_t cActive  = 0;
+        uint32_t cMax     = RTMpGetCpuGroupCounts(idxGroup, &cActive);
+        uint32_t cbNeeded = RT_OFFSETOF(SUPGIPCPUGROUP, aiCpuSetIdxs[cMax]);
+        AssertReturn(cbNeeded <= cbGipCpuGroups, VERR_INTERNAL_ERROR_3);
+        AssertReturn(cActive <= cMax, VERR_INTERNAL_ERROR_4);
+
+        pGip->aoffCpuGroup[idxGroup] = (uint16_t)((uintptr_t)pGroup - (uintptr_t)pGip);
+        pGroup->cMembers    = cActive;
+        pGroup->cMaxMembers = cMax;
+        for (uint32_t idxMember = 0; idxMember < cMax; idxMember++)
+        {
+            pGroup->aiCpuSetIdxs[idxMember] = RTMpSetIndexFromCpuGroupMember(idxGroup, idxMember);
+            Assert((unsigned)pGroup->aiCpuSetIdxs[idxMember] < pGip->cPossibleCpus);
+        }
+
+        /* advance. */
+        cbGipCpuGroups -= cbNeeded;
+        pGroup = (PSUPGIPCPUGROUP)&pGroup->aiCpuSetIdxs[cMax];
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+void VBOXCALL supdrvOSGipInitGroupBitsForCpu(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pGipCpu)
+{
+    NOREF(pDevExt);
+
+    /*
+     * Translate the CPU index into a group and member.
+     */
+    PROCESSOR_NUMBER ProcNum = { 0, pGipCpu->iCpuSet, 0 };
+    if (g_pfnKeGetProcessorNumberFromIndex)
+    {
+        NTSTATUS rcNt = g_pfnKeGetProcessorNumberFromIndex(pGipCpu->iCpuSet, &ProcNum);
+        if (NT_SUCCESS(rcNt))
+            Assert(ProcNum.Group < g_pfnKeQueryMaximumGroupCount());
+        else
+        {
+            AssertFailed();
+            ProcNum.Group  = 0;
+            ProcNum.Number = pGipCpu->iCpuSet;
+        }
+    }
+    pGipCpu->iCpuGroup       = ProcNum.Group;
+    pGipCpu->iCpuGroupMember = ProcNum.Number;
+
+    /*
+     * Update the group info.  Just do this wholesale for now (doesn't scale well).
+     */
+    for (uint32_t idxGroup = 0; idxGroup < pGip->cPossibleCpuGroups; idxGroup++)
+        if (pGip->aoffCpuGroup[idxGroup] != UINT16_MAX)
+        {
+            PSUPGIPCPUGROUP pGroup = (PSUPGIPCPUGROUP)((uintptr_t)pGip + pGip->aoffCpuGroup[idxGroup]);
+
+            uint32_t cActive  = 0;
+            uint32_t cMax     = RTMpGetCpuGroupCounts(idxGroup, &cActive);
+            AssertStmt(cMax == pGroup->cMaxMembers, cMax = pGroup->cMaxMembers);
+            AssertStmt(cActive <= cMax, cActive = cMax);
+            if (pGroup->cMembers != cActive)
+                pGroup->cMembers = cActive;
+
+            for (uint32_t idxMember = 0; idxMember < cMax; idxMember++)
+            {
+                int idxCpuSet = RTMpSetIndexFromCpuGroupMember(idxGroup, idxMember);
+                AssertMsg((unsigned)idxCpuSet < pGip->cPossibleCpus,
+                          ("%d vs %d for %u.%u\n", idxCpuSet, pGip->cPossibleCpus, idxGroup, idxMember));
+
+                if (pGroup->aiCpuSetIdxs[idxMember] != idxCpuSet)
+                    pGroup->aiCpuSetIdxs[idxMember] = idxCpuSet;
+            }
+        }
+}
+
+
 /**
  * Initializes any OS specific object creator fields.
  */
@@ -1679,7 +1844,7 @@ bool VBOXCALL   supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, c
 bool VBOXCALL  supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt)
 {
     RT_NOREF1(pDevExt);
-    return false;
+    return g_Options.fOptForceAsyncTsc != 0;
 }
 
 
diff --git a/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c b/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
index 2cfc8ed..eff3c04 100644
--- a/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
+++ b/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
@@ -933,7 +933,16 @@ static int vboxNetFltLinuxPacketHandler(struct sk_buff *pBuf,
         dev_kfree_skb(pBuf);
         if (!pCopy)
         {
-            LogRel(("VBoxNetFlt: Failed to allocate packet buffer, dropping the packet.\n"));
+            static volatile uint32_t s_cMessages  = 0;
+            static volatile uint32_t s_cThreshold = 1;
+            if (ASMAtomicIncU32(&s_cMessages) == ASMAtomicReadU32(&s_cThreshold))
+            {
+                LogRel(("VBoxNetFlt: Failed to allocate packet buffer, dropping the packet.\n"));
+                if (ASMAtomicReadU32(&s_cMessages) != 1)
+                    LogRel(("VBoxNetFlt: (the above error has occured %u times so far)\n",
+                            ASMAtomicReadU32(&s_cMessages)));
+                ASMAtomicWriteU32(&s_cThreshold, ASMAtomicReadU32(&s_cThreshold) * 10);
+            }
             return 0;
         }
         pBuf = pCopy;
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py b/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py
old mode 100644
new mode 100755
index be5069a..cbe1061
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 
 num_get_values = {
     'GL_ACCUM_ALPHA_BITS' : 1,
@@ -411,47 +412,47 @@ extensions_num_get_values = {
     'GL_ACTIVE_STENCIL_FACE_EXT': (1, 'CR_EXT_stencil_two_side'),
 }
 
-get_keys = num_get_values.keys() + extensions_num_get_values.keys()
+get_keys = list(num_get_values.keys()) + list(extensions_num_get_values.keys())
 get_keys.sort()
 max_keyvalues = 0
 
-print """
+print("""
 static struct nv_struct { GLenum pname; unsigned int num_values;
 #ifdef VBOX_WITH_CRDUMPER 
 const char* pszName;
 #endif
 } num_values_array[] = {
-"""
+""")
 for key in get_keys:
     try:
         keyvalues = num_get_values[key]
         if max_keyvalues < keyvalues:
             max_keyvalues = keyvalues
-        print """
+        print("""
         \t{ %s, %d
 #ifdef VBOX_WITH_CRDUMPER
             , "%s"
 #endif
         },
-        """ % (key, keyvalues, key)
+        """ % (key, keyvalues, key))
     except KeyError:
         (nv, ifdef) = extensions_num_get_values[key]
         if max_keyvalues < nv:
             max_keyvalues = nv
-        print '#ifdef %s' % ifdef
-        print """
+        print('#ifdef %s' % ifdef)
+        print("""
         \t{ %s, %d
         #ifdef VBOX_WITH_CRDUMPER
             , "%s"
         #endif
         },
-        """ % (key, nv, key)
-        print '#endif /* %s */' % ifdef
-print "\t{ 0, 0 }"
-print "};"
-print "#define CR_MAX_GET_VALUES %d" % max_keyvalues
+        """ % (key, nv, key))
+        print('#endif /* %s */' % ifdef)
+print("\t{ 0, 0 }")
+print("};")
+print("#define CR_MAX_GET_VALUES %d" % max_keyvalues)
 
-print """
+print("""
 static unsigned int __numValues( GLenum pname )
 {
     struct nv_struct *temp;
@@ -464,4 +465,4 @@ static unsigned int __numValues( GLenum pname )
     crDebug( "Invalid pname to __numValues: 0x%x\\n", (int) pname );
     return 0;
 }
-"""
+""")
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py
old mode 100644
new mode 100755
index 9e5b539..de765f0
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys, string, re
 
 import apiutil
@@ -11,7 +12,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_dispatch.py SCRIPT */
 #include "cr_spu.h"
 #include "chromium.h"
@@ -21,7 +22,7 @@ print """
 #include "cr_unpack.h"
 
 CRCurrentStatePointers crServerCurrent;
-"""
+""")
 
 
 for func_name in apiutil.AllSpecials( sys.argv[1]+"/../state_tracker/state" ):
@@ -32,14 +33,14 @@ for func_name in apiutil.AllSpecials( sys.argv[1]+"/../state_tracker/state" ):
 
     wrap = apiutil.GetCategoryWrapper(func_name)
     if wrap:
-        print '#if defined(CR_%s)' % wrap
-    print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString( params ) )
-    print '{'
-    print '\tcrState%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
-    print '\tcr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
-    print '}'
+        print('#if defined(CR_%s)' % wrap)
+    print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString( params ) ))
+    print('{')
+    print('\tcrState%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
+    print('\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
+    print('}')
     if wrap:
-        print '#endif'
+        print('#endif')
 
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
@@ -50,17 +51,17 @@ for func_name in keys:
     m = re.search( r"^(Color|Normal)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
     if m :
         current = 1
-        name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = m.group(3) + m.group(2)
     m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)(EXT)$", func_name )
     if m :
         current = 1
-        name = string.lower(m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = m.group(3) + m.group(2)
     m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
     if m :
         current = 1
-        name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = m.group(3) + m.group(2)
         array = "[0]"
     m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name )
@@ -73,24 +74,24 @@ for func_name in keys:
     m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name )
     if m :
         current = 1
-        name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = m.group(2) + "1"
     m = re.match( r"^(EdgeFlag)$", func_name )
     if m :
         current = 1
-        name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = "l1"
     m = re.match( r"^(FogCoord)(f|d)(EXT)$", func_name)
     if m :
         current = 1
-        name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = m.group(2) + "1"
         
     # Vertex attribute commands w/ some special cases
     m = re.search( r"^(VertexAttrib)([1234])(s|i|f|d)ARB$", func_name )
     if m :
         current = 1
-        name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
+        name = m.group(1)[:1].lower() + m.group(1)[1:]
         type = m.group(3) + m.group(2)
         array = "[index]"
         condition = "if (index < CR_MAX_VERTEX_ATTRIBS)"
@@ -103,21 +104,21 @@ for func_name in keys:
 
     if current:
         params = apiutil.Parameters(func_name)
-        print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params) )
-        print '{'
-        print '\t%s' % (condition)
-        print '\t{'
-        print '\t\tcr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString(params) )
-        print "\t\tcr_server.current.c.%s.%s%s = cr_unpackData;" % (name,type,array)
-        print '\t}'
-        print '}\n' 
-
-print """
+        print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
+        print('{')
+        print('\t%s' % (condition))
+        print('\t{')
+        print('\t\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallString(params) ))
+        print("\t\tcr_server.current.c.%s.%s%s = cr_unpackData;" % (name,type,array))
+        print('\t}')
+        print('}\n')
+
+print("""
 void crServerInitDispatch(void)
 {
     crSPUInitDispatchTable( &(cr_server.dispatch) );
     crSPUCopyDispatchTable( &(cr_server.dispatch), &(cr_server.head_spu->dispatch_table ) );
-"""
+""")
 
 for func_name in keys:
     if ("get" in apiutil.Properties(func_name) or
@@ -126,11 +127,11 @@ for func_name in keys:
 
         wrap = apiutil.GetCategoryWrapper(func_name)
         if wrap:
-            print '#if defined(CR_%s)' % wrap
+            print('#if defined(CR_%s)' % wrap)
             
-        print '\tcr_server.dispatch.%s = crServerDispatch%s;' % (func_name, func_name)
+        print('\tcr_server.dispatch.%s = crServerDispatch%s;' % (func_name, func_name))
         if wrap:
-            print '#endif'
+            print('#endif')
 
-print '}'
+print('}')
 
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch_header.py b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch_header.py
old mode 100644
new mode 100755
index 9ac9895..7db1a1e
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch_header.py
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch_header.py
@@ -3,13 +3,14 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_dispatch_header.py SCRIPT */
 #ifndef SERVER_DISPATCH_HEADER
 #define SERVER_DISPATCH_HEADER
@@ -27,7 +28,7 @@ print """
 extern "C" {
 #endif
 
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -39,12 +40,12 @@ for func_name in keys:
         params = apiutil.Parameters(func_name)
         return_type = apiutil.ReturnType(func_name)
         
-        print '%s SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString( params ))
+        print('%s SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString( params )))
 
-print """
+print("""
 #if defined(__cplusplus)
 }
 #endif
 
 #endif /* SERVER_DISPATCH_HEADER */
-"""
+""")
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_get.py b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_get.py
old mode 100644
new mode 100755
index 58d4953..8463a1f
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_get.py
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_get.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 #include "cr_spu.h"
 #include "chromium.h"
 #include "cr_error.h"
@@ -18,7 +19,7 @@ print """
 #include "cr_net.h"
 #include "server_dispatch.h"
 #include "server.h"
-"""
+""")
 
 max_components = {
     'GetClipPlane': 4,
@@ -117,28 +118,28 @@ for func_name in keys:
 
         params = apiutil.Parameters(func_name)
 
-        print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % (func_name, apiutil.MakeDeclarationString( params ) )
-        print '{'
+        print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % (func_name, apiutil.MakeDeclarationString( params ) ))
+        print('{')
 
         lastParam = params[-1]
         assert apiutil.IsPointer(lastParam[1])
         local_argtype = apiutil.PointerType(lastParam[1])
         local_argname = 'local_%s' % lastParam[0]
 
-        print '\t%s %s[%d];' % ( local_argtype, local_argname, max_components[func_name] )
-        print '\t(void) %s;' % lastParam[0]
+        print('\t%s %s[%d];' % ( local_argtype, local_argname, max_components[func_name] ))
+        print('\t(void) %s;' % lastParam[0])
 
         params[-1] = (local_argname, local_argtype, 0)
 
-        print '\tcr_server.head_spu->dispatch_table.%s( %s );' % ( func_name, apiutil.MakeCallString(params) )
+        print('\tcr_server.head_spu->dispatch_table.%s(%s);' % ( func_name, apiutil.MakeCallString(params) ))
 
         if func_name in convert_bufferid:
-            print '\tif (pname==GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB){'
-            print '\t\tlocal_params[0]=(%s)crStateBufferHWIDtoID((GLint)local_params[0]);' % (local_argtype);
-            print '\t}'
+            print('\tif (pname==GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB){')
+            print('\t\tlocal_params[0]=(%s)crStateBufferHWIDtoID((GLint)local_params[0]);' % (local_argtype))
+            print('\t}')
 
         if func_name in no_pnames:
-            print '\tcrServerReturnValue( &(%s[0]), %d*sizeof(%s) );' % (local_argname, max_components[func_name], local_argtype );
+            print('\tcrServerReturnValue(&(%s[0]), %d*sizeof(%s));' % (local_argname, max_components[func_name], local_argtype ))
         else:
-            print '\tcrServerReturnValue( &(%s[0]), crStateHlpComponentsCount(pname)*sizeof(%s) );' % (local_argname, local_argtype );
-        print '}\n'
+            print('\tcrServerReturnValue(&(%s[0]), crStateHlpComponentsCount(pname)*sizeof(%s));' % (local_argname, local_argtype ))
+        print ('}\n')
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py
old mode 100644
new mode 100755
index 55fdd36..6778f34
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """
+print("""
 /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_retval.py SCRIPT */
 #include "chromium.h"
 #include "cr_mem.h"
@@ -55,7 +56,7 @@ void crServerReturnValue( const void *payload, unsigned int payload_len )
     CRDBGPTR_SETZ(&cr_server.writeback_ptr);
     CRDBGPTR_SETZ(&cr_server.return_ptr);
 }
-"""
+""")
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
 
@@ -67,10 +68,10 @@ for func_name in keys:
     if "VBox" == apiutil.Category(func_name):
         continue
     if return_type != 'void':
-        print '%s SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString(params))
-        print '{'
-        print '\t%s retval;' % return_type
-        print '\tretval = cr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString(params) );
-        print '\tcrServerReturnValue( &retval, sizeof(retval) );'
-        print '\treturn retval; /* WILL PROBABLY BE IGNORED */'
-        print '}'
+        print('%s SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString(params)))
+        print('{')
+        print('\t%s retval;' % return_type)
+        print('\tretval = cr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallString(params) ))
+        print('\tcrServerReturnValue( &retval, sizeof(retval) );')
+        print('\treturn retval; /* WILL PROBABLY BE IGNORED */')
+        print('}')
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py
index 1698841..3ccda91 100755
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,14 +11,14 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """#include "cr_spu.h"
+print("""#include "cr_spu.h"
 #include "chromium.h"
 #include "cr_error.h"
 #include "cr_mem.h"
 #include "cr_net.h"
 #include "server_dispatch.h"
 #include "server.h"
-"""
+""")
 
 from get_sizes import *;
 
@@ -28,11 +29,11 @@ types = [ 'GLint', 'GLfloat', 'GLdouble', 'GLboolean' ]
 for index in range(len(funcs)):
     func_name = funcs[index]
     params = apiutil.Parameters(func_name)
-    print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params))
-    print '{'
-    print '\t%s *get_values;' % types[index]
-    print '\tint tablesize;'
-    print """
+    print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params)))
+    print('{')
+    print('\t%s *get_values;' % types[index])
+    print('\tint tablesize;')
+    print("""
     #ifdef CR_ARB_texture_compression
     if (GL_COMPRESSED_TEXTURE_FORMATS_ARB == pname)
     {
@@ -45,12 +46,12 @@ for index in range(len(funcs)):
     {
         tablesize = __numValues( pname ) * sizeof(%s);
     }
-    """ % (types[index], types[index])
-    print '\t(void) params;'
-    print '\tget_values = (%s *) crAlloc( tablesize );' % types[index]
-    print '\tif (tablesize>0)'
-    print '\tcr_server.head_spu->dispatch_table.%s( pname, get_values );' % func_name
-    print """
+    """ % (types[index], types[index]))
+    print('\t(void) params;')
+    print('\tget_values = (%s *) crAlloc( tablesize );' % types[index])
+    print('\tif (tablesize>0)')
+    print('\tcr_server.head_spu->dispatch_table.%s( pname, get_values );' % func_name)
+    print("""
     if (GL_TEXTURE_BINDING_1D==pname
         || GL_TEXTURE_BINDING_2D==pname
         || GL_TEXTURE_BINDING_3D==pname
@@ -145,7 +146,7 @@ for index in range(len(funcs)):
             *get_values = (%s)CR_MAX_VERTEX_ATTRIBS;
         } 
     }
-    """ % (types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index])
-    print '\tcrServerReturnValue( get_values, tablesize );'
-    print '\tcrFree(get_values);'
-    print '}\n'
+    """ % (types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index]))
+    print('\tcrServerReturnValue( get_values, tablesize );')
+    print('\tcrFree(get_values);')
+    print('}\n')
diff --git a/src/VBox/HostServices/SharedOpenGL/dlm/dlm_generated.py b/src/VBox/HostServices/SharedOpenGL/dlm/dlm_generated.py
index dfbb682..8371b9d 100755
--- a/src/VBox/HostServices/SharedOpenGL/dlm/dlm_generated.py
+++ b/src/VBox/HostServices/SharedOpenGL/dlm/dlm_generated.py
@@ -196,7 +196,7 @@ def wrap_compile(functionName):
     if "useclient" in props or "pixelstore" in props:
         callstring += ", c"
         argstring += ", CRClientState *c"
-    print 'void DLM_APIENTRY crDLMCompile%s( %s )' % (functionName, argstring)
+    print 'void DLM_APIENTRY crDLMCompile%s(%s)' % (functionName, argstring)
     print '{'
     print '    CRDLMContextState *state = CURRENT_STATE();'
     print '    struct instance%s *instance;' % (functionName)
diff --git a/src/VBox/HostServices/SharedOpenGL/dlm/dlm_header.py b/src/VBox/HostServices/SharedOpenGL/dlm/dlm_header.py
index ed99ea3..f68ccaa 100644
--- a/src/VBox/HostServices/SharedOpenGL/dlm/dlm_header.py
+++ b/src/VBox/HostServices/SharedOpenGL/dlm/dlm_header.py
@@ -237,7 +237,7 @@ for func_name in keys:
 			argstring = argstring + ", CRClientState *c"
 
 		if mode == 'header':
-			print 'extern void DLM_APIENTRY crDLMCompile%s( %s );' % (func_name, argstring)
+			print 'extern void DLM_APIENTRY crDLMCompile%s(%s);' % (func_name, argstring)
 		elif mode == 'defs':
 			print "crDLMCompile%s" % func_name
 
@@ -261,7 +261,7 @@ for func_name in keys:
 		params = apiutil.Parameters(func_name)
 		argstring = apiutil.MakeDeclarationString(params)
 		if mode == 'header':
-			print 'int DLM_APIENTRY crDLMCheckList%s( %s );' % (func_name, argstring)
+			print 'int DLM_APIENTRY crDLMCheckList%s(%s);' % (func_name, argstring)
 		elif mode == 'defs':
 			print "crDLMCheckList%s" % func_name
 
diff --git a/src/VBox/HostServices/SharedOpenGL/expando/expando.py b/src/VBox/HostServices/SharedOpenGL/expando/expando.py
index f7bedfb..86c4595 100644
--- a/src/VBox/HostServices/SharedOpenGL/expando/expando.py
+++ b/src/VBox/HostServices/SharedOpenGL/expando/expando.py
@@ -44,7 +44,7 @@ for func_name in generatedFunctions:
 	if apiutil.CanCompile(func_name):
 		needDL = 1
 
-	print 'static %s EXPANDOSPU_APIENTRY expando%s( %s )' % ( return_type, func_name, declarationString)
+	print 'static %s EXPANDOSPU_APIENTRY expando%s(%s)' % ( return_type, func_name, declarationString)
 	print '{'
 	if needDL:
 		print '\tGLenum dlMode = crDLMGetCurrentMode();'
@@ -74,7 +74,7 @@ for func_name in generatedFunctions:
 	else:
 	    print '\texpando_spu.super.%s(%s);' % (func_name, basicCallString)
 	if apiutil.SetsClientState(func_name):
-		print '\tcrState%s( %s );' % (func_name, basicCallString)	
+		print '\tcrState%s(%s);' % (func_name, basicCallString)	
 	
 	if return_type != "void":
 	    print "\treturn rc;"
diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py
old mode 100644
new mode 100755
index 7329bb2..88807c0
--- a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py
+++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 import apiutil
@@ -10,7 +11,7 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack.py */
+print("""/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack.py */
 
 #include "unpacker.h"
 #include "cr_opcodes.h"
@@ -39,7 +40,7 @@ static void crUnpackExtendDbg(void);
 static GLenum g_VBoxDbgCrPrevOpcode = 0;
 static GLenum g_VBoxDbgCrPrevExtendOpcode = 0;
 #endif
-"""
+""")
 
 nodebug_opcodes = [
     "CR_MULTITEXCOORD2FARB_OPCODE",
@@ -69,9 +70,9 @@ def ReadData( offset, arg_type ):
     """Emit a READ_DOUBLE or READ_DATA call for pulling a GL function
     argument out of the buffer's operand area."""
     if arg_type == "GLdouble" or arg_type == "GLclampd":
-        retval = "READ_DOUBLE( %d )" % offset
+        retval = "READ_DOUBLE(%d)" % offset
     else:
-        retval = "READ_DATA( %d, %s )" % (offset, arg_type)
+        retval = "READ_DATA(%d, %s)" % (offset, arg_type)
     return retval
 
 
@@ -80,10 +81,10 @@ def FindReturnPointer( return_type, params ):
     through a pointer parameter) emit a SET_RETURN_PTR call."""
     arg_len = apiutil.PacketLength( params )
     if (return_type != 'void'):
-        print '\tSET_RETURN_PTR( %d );' % (arg_len + 8) # extended opcode plus packet length
+        print('\tSET_RETURN_PTR(%d);' % (arg_len + 8)) # extended opcode plus packet length
     else:
         paramList = [ ('foo', 'void *', 0) ]
-        print '\tSET_RETURN_PTR( %d );' % (arg_len + 8 - apiutil.PacketLength(paramList))
+        print('\tSET_RETURN_PTR(%d);' % (arg_len + 8 - apiutil.PacketLength(paramList)))
 
 
 def FindWritebackPointer( return_type, params ):
@@ -93,7 +94,7 @@ def FindWritebackPointer( return_type, params ):
         paramList = [ ('foo', 'void *', 0) ]
         arg_len += apiutil.PacketLength( paramList )
 
-    print '\tSET_WRITEBACK_PTR( %d );' % (arg_len + 8) # extended opcode plus packet length
+    print('\tSET_WRITEBACK_PTR(%d);' % (arg_len + 8)) # extended opcode plus packet length
 
 
 def MakeNormalCall( return_type, func_name, params, counter_init = 0 ):
@@ -106,9 +107,9 @@ def MakeNormalCall( return_type, func_name, params, counter_init = 0 ):
             params[i] = ('NULL', type, vecSize)
             copy_of_params[i] = (copy_of_params[i][0], 'void', 0)
             if not "get" in apiutil.Properties(func_name):
-                print '\tcrError( "%s needs to be special cased!" );' % func_name
+                print('\tcrError( "%s needs to be special cased!" );' % func_name)
         else:
-            print "\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) )
+            print("\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) ))
         counter += apiutil.sizeof(copy_of_params[i][1])
 
     if ("get" in apiutil.Properties(func_name)):
@@ -116,10 +117,10 @@ def MakeNormalCall( return_type, func_name, params, counter_init = 0 ):
         FindWritebackPointer( return_type, params )
 
     if return_type != "void":
-        print "\t(void)",
+        print("\t(void)", end=" ")
     else:
-        print "\t",
-    print "cr_unpackDispatch.%s( %s );" % (func_name, apiutil.MakeCallString(params))
+        print("\t", end="")
+    print("cr_unpackDispatch.%s(%s);" % (func_name, apiutil.MakeCallString(params)))
 
 
 def MakeVectorCall( return_type, func_name, arg_type ):
@@ -130,23 +131,23 @@ def MakeVectorCall( return_type, func_name, arg_type ):
     (arg_name, vecType, vecSize) = params[0]
 
     if arg_type == "GLdouble" or arg_type == "GLclampd":
-        print "#ifdef CR_UNALIGNED_ACCESS_OKAY"
-        print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType)
-        print "#else"
+        print("#ifdef CR_UNALIGNED_ACCESS_OKAY")
+        print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType))
+        print("#else")
         for index in range(0, vecSize):
-            print "\tGLdouble v" + `index` + " = READ_DOUBLE(", `index * 8`, ");"
+            print("\tGLdouble v" + repr(index) + " = READ_DOUBLE(" + repr(index * 8) + ");")
         if return_type != "void":
-            print "\t(void) cr_unpackDispatch.%s(" % func_name,
+            print("\t(void) cr_unpackDispatch.%s(" % func_name, end="")
         else:
-            print "\tcr_unpackDispatch.%s(" % func_name,
+            print("\tcr_unpackDispatch.%s(" % func_name, end="")
         for index in range(0, vecSize):
-            print "v" + `index`,
+            print("v" + repr(index), end="")
             if index != vecSize - 1:
-                print ",",
-        print ");"
-        print "#endif"
+                print(",", end=" ")
+        print(");")
+        print("#endif")
     else:
-        print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType)
+        print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType))
 
 
 
@@ -164,8 +165,8 @@ for func_name in keys:
     params = apiutil.Parameters(func_name)
     return_type = apiutil.ReturnType(func_name)
     
-    print "static void crUnpack%s(void)" % func_name
-    print "{"
+    print("static void crUnpack%s(void)" % func_name)
+    print("{")
 
     vector_func = apiutil.VectorFunction(func_name)
     if (vector_func and len(apiutil.Parameters(vector_func)) == 1):
@@ -174,16 +175,16 @@ for func_name in keys:
         MakeNormalCall( return_type, func_name, params )
     packet_length = apiutil.PacketLength( params )
     if packet_length == 0:
-        print "\tINCR_DATA_PTR_NO_ARGS( );"
+        print("\tINCR_DATA_PTR_NO_ARGS( );")
     else:
-        print "\tINCR_DATA_PTR( %d );" % packet_length
-    print "}\n"
+        print("\tINCR_DATA_PTR(%d);" % packet_length)
+    print("}\n")
 
 
 #
 # Emit some code
 #
-print """ 
+print(""" 
 typedef struct __dispatchNode {
     const unsigned char *unpackData;
     struct __dispatchNode *next;
@@ -256,7 +257,7 @@ void crUnpack( const void *data, const void *opcodes,
     crDebug("crUnpack: %d opcodes", num_opcodes);
 #endif
 
-    for (i = 0 ; i < num_opcodes ; i++)
+    for (i = 0; i < num_opcodes; i++)
     {
     
         CRDBGPTR_CHECKZ(writeback_ptr);
@@ -267,25 +268,25 @@ void crUnpack( const void *data, const void *opcodes,
         g_VBoxDbgCrPrevOpcode = *unpack_opcodes;
 #endif
         switch( *unpack_opcodes )
-        {"""
+        {""")
 
 #
 # Emit switch cases for all unextended opcodes
 #
 for func_name in keys:
     if "pack" in apiutil.ChromiumProps(func_name):
-        print '\t\t\tcase %s:' % apiutil.OpcodeName( func_name )
+        print('\t\t\tcase %s:' % apiutil.OpcodeName( func_name ))
         if not apiutil.OpcodeName(func_name) in nodebug_opcodes:
-            print """
+            print("""
 #ifdef CR_UNPACK_DEBUG_LAST_OPCODES
                 if (i==(num_opcodes-1))
 #endif
 #if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES)
                 crDebug("Unpack: %s");
-#endif """ % apiutil.OpcodeName(func_name)
-        print '\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name
+#endif """ % apiutil.OpcodeName(func_name))
+        print('\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name)
 
-print """       
+print("""       
             case CR_EXTEND_OPCODE:
                 #ifdef CR_UNPACK_DEBUG_OPCODES 
                     crUnpackExtendDbg();
@@ -313,7 +314,7 @@ print """
         
         unpack_opcodes--;
     }
-}"""
+}""")
 
 
 #
@@ -324,22 +325,22 @@ for func_name in keys:
             and not apiutil.FindSpecial("unpacker", func_name)):
             return_type = apiutil.ReturnType(func_name)
             params = apiutil.Parameters(func_name)
-            print 'static void crUnpackExtend%s(void)' % func_name
-            print '{'
+            print('static void crUnpackExtend%s(void)' % func_name)
+            print('{')
             MakeNormalCall( return_type, func_name, params, 8 )
-            print '}\n'
+            print('}\n')
 
-print 'static void crUnpackExtend(void)'
-print '{'
-print '\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' );
-print ''
-print '#ifdef CR_UNPACK_DEBUG_PREV_OPCODES'
-print '\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;'
-print '#endif'
-print ''
-print '\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/'
-print '\tswitch( extend_opcode )'
-print '\t{'
+print('static void crUnpackExtend(void)')
+print('{')
+print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ))
+print('')
+print('#ifdef CR_UNPACK_DEBUG_PREV_OPCODES')
+print('\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;')
+print('#endif')
+print('')
+print('\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/')
+print('\tswitch( extend_opcode )')
+print('\t{')
 
 
 #
@@ -347,29 +348,29 @@ print '\t{'
 #
 for func_name in keys:
     if "extpack" in apiutil.ChromiumProps(func_name):
-        print '\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name )
-#        print '\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )
-        print '\t\t\tcrUnpackExtend%s( );' % func_name
-        print '\t\t\tbreak;'
+        print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ))
+#        print('\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )))
+        print('\t\t\tcrUnpackExtend%s( );' % func_name)
+        print('\t\t\tbreak;')
 
-print """       default:
+print("""       default:
             crError( "Unknown extended opcode: %d", (int) extend_opcode );
             break;
     }
     INCR_VAR_PTR();
-}"""
+}""")
 
-print 'static void crUnpackExtendDbg(void)'
-print '{'
-print '\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' );
-print ''
-print '#ifdef CR_UNPACK_DEBUG_PREV_OPCODES'
-print '\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;'
-print '#endif'
-print ''
-print '\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/'
-print '\tswitch( extend_opcode )'
-print '\t{'
+print('static void crUnpackExtendDbg(void)')
+print('{')
+print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ))
+print('')
+print('#ifdef CR_UNPACK_DEBUG_PREV_OPCODES')
+print('\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;')
+print('#endif')
+print('')
+print('\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/')
+print('\tswitch( extend_opcode )')
+print('\t{')
 
 
 #
@@ -377,15 +378,15 @@ print '\t{'
 #
 for func_name in keys:
     if "extpack" in apiutil.ChromiumProps(func_name):
-        print '\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name )
+        print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ))
         if not apiutil.ExtendedOpcodeName(func_name) in nodebug_extopcodes:
-            print '\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )
-        print '\t\t\tcrUnpackExtend%s( );' % func_name
-        print '\t\t\tbreak;'
+            print('\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name ))
+        print('\t\t\tcrUnpackExtend%s( );' % func_name)
+        print('\t\t\tbreak;')
 
-print """       default:
+print("""       default:
             crError( "Unknown extended opcode: %d", (int) extend_opcode );
             break;
     }
     INCR_VAR_PTR();
-}"""
+}""")
diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py
old mode 100644
new mode 100755
index 6910802..10e995a
--- a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py
+++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py
@@ -3,6 +3,7 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys
 
 sys.path.append( "../glapi_parser" )
@@ -11,12 +12,12 @@ import apiutil
 
 apiutil.CopyrightC()
 
-print """/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack_extend.py */
+print("""/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack_extend.py */
 
 #ifndef UNPACK_EXTEND_H
 #define UNPACK_EXTEND_H 1
 
-"""
+""")
 
 
 #
@@ -24,12 +25,12 @@ print """/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack_extend.py */
 #
 for func_name in apiutil.AllSpecials( "unpacker" ):
 	if "extpack" in apiutil.ChromiumProps(func_name):
-		print 'extern void crUnpackExtend%s(void);' % func_name
+		print('extern void crUnpackExtend%s(void);' % func_name)
 	else:
-		print 'extern void crUnpack%s(void);' % func_name
+		print('extern void crUnpack%s(void);' % func_name)
 
-print """
+print("""
 #endif
-"""
+""")
 
 
diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py
old mode 100644
new mode 100755
index b507b0f..cb42c22
--- a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py
+++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py
@@ -3,8 +3,9 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
 
+from __future__ import print_function
 import sys;
-import cPickle;
+import pickle;
 import types;
 import string;
 import re;
@@ -14,19 +15,16 @@ sys.path.append( "../opengl_stub" )
 import stub_common;
 
 parsed_file = open( "../glapi_parser/gl_header.parsed", "rb" )
-gl_mapping = cPickle.load( parsed_file )
+gl_mapping = pickle.load( parsed_file )
 
 stub_common.CopyrightC()
 
-print """#ifndef CR_UNPACKFUNCTIONS_H
+print("""#ifndef CR_UNPACKFUNCTIONS_H
 #define CR_UNPACKFUNCTIONS_H
-"""
+""")
 
-keys = gl_mapping.keys()
-keys.sort()
-
-for func_name in keys:
+for func_name in sorted(gl_mapping.keys()):
 	( return_type, arg_names, arg_types ) = gl_mapping[func_name]
-	print 'void crUnpack%s();' %( func_name )
-print 'void crUnpackExtend();'
-print '\n#endif /* CR_UNPACKFUNCTIONS_H */'
+	print('void crUnpack%s();' %( func_name ))
+print('void crUnpackExtend();')
+print('\n#endif /* CR_UNPACKFUNCTIONS_H */')
diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c
index 2e530b6..2e22a6e 100644
--- a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c
+++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c
@@ -9,82 +9,82 @@
 #include "cr_mem.h"
 
 
-void crUnpackMap2d( void  )
+void crUnpackMap2d(void)
 {
-	GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLdouble u1 = READ_DOUBLE( sizeof( int ) + 4 );
-	GLdouble u2 = READ_DOUBLE( sizeof( int ) + 12 );
-	GLint ustride = READ_DATA( sizeof( int ) + 20, GLint );
-	GLint uorder = READ_DATA( sizeof( int ) + 24, GLint );
-	GLdouble v1 = READ_DOUBLE( sizeof( int ) + 28 );
-	GLdouble v2 = READ_DOUBLE( sizeof( int ) + 36 );
-	GLint vstride = READ_DATA( sizeof( int ) + 44, GLint );
-	GLint vorder = READ_DATA( sizeof( int ) + 48, GLint );
+	GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
+	GLdouble u1 = READ_DOUBLE(sizeof(int) + 4);
+	GLdouble u2 = READ_DOUBLE(sizeof(int) + 12);
+	GLint ustride = READ_DATA(sizeof(int) + 20, GLint);
+	GLint uorder = READ_DATA(sizeof(int) + 24, GLint);
+	GLdouble v1 = READ_DOUBLE(sizeof(int) + 28);
+	GLdouble v2 = READ_DOUBLE(sizeof(int) + 36);
+	GLint vstride = READ_DATA(sizeof(int) + 44, GLint);
+	GLint vorder = READ_DATA(sizeof(int) + 48, GLint);
 
-	int n_points = READ_DATA( 0, int ) - ( sizeof( int ) + 52 );
+	int n_points = READ_DATA(0, int) - (sizeof(int) + 52);
 	GLdouble *points;
 
-	if ( n_points & 0x7 )
-		crError( "crUnpackMap2d: n_points=%d, expected multiple of 8\n", n_points );
-	points = (GLdouble *) crAlloc( n_points );
-	crMemcpy( points, DATA_POINTER( sizeof(int) + 52, GLdouble ), n_points );
+	if (n_points & 0x7)
+		crError("crUnpackMap2d: n_points=%d, expected multiple of 8\n", n_points);
+	points = (GLdouble *) crAlloc(n_points);
+	crMemcpy(points, DATA_POINTER(sizeof(int) + 52, GLdouble), n_points);
 
-	cr_unpackDispatch.Map2d( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, 
-			 points );
-	crFree( points );
+	cr_unpackDispatch.Map2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, 
+			 points);
+	crFree(points);
 
 	INCR_VAR_PTR();
 }
 
-void crUnpackMap2f( void  )
+void crUnpackMap2f(void)
 {
-	GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLfloat u1 = READ_DATA( sizeof( int ) + 4, GLfloat );
-	GLfloat u2 = READ_DATA( sizeof( int ) + 8, GLfloat );
-	GLint ustride = READ_DATA( sizeof( int ) + 12, GLint );
-	GLint uorder = READ_DATA( sizeof( int ) + 16, GLint );
-	GLfloat v1 = READ_DATA( sizeof( int ) + 20, GLfloat );
-	GLfloat v2 = READ_DATA( sizeof( int ) + 24, GLfloat );
-	GLint vstride = READ_DATA( sizeof( int ) + 28, GLint );
-	GLint vorder = READ_DATA( sizeof( int ) + 32, GLint );
-	GLfloat *points = DATA_POINTER( sizeof( int ) + 36 , GLfloat );
+	GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
+	GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat);
+	GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat);
+	GLint ustride = READ_DATA(sizeof(int) + 12, GLint);
+	GLint uorder = READ_DATA(sizeof(int) + 16, GLint);
+	GLfloat v1 = READ_DATA(sizeof(int) + 20, GLfloat);
+	GLfloat v2 = READ_DATA(sizeof(int) + 24, GLfloat);
+	GLint vstride = READ_DATA(sizeof(int) + 28, GLint);
+	GLint vorder = READ_DATA(sizeof(int) + 32, GLint);
+	GLfloat *points = DATA_POINTER(sizeof(int) + 36 , GLfloat);
 
-	cr_unpackDispatch.Map2f( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
-			 points );
+	cr_unpackDispatch.Map2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
+			 points);
 	INCR_VAR_PTR();
 }
 
-void crUnpackMap1d( void  )
+void crUnpackMap1d(void)
 {
-	GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLdouble u1 = READ_DOUBLE( sizeof( int ) + 4 );
-	GLdouble u2 = READ_DOUBLE( sizeof( int ) + 12 );
-	GLint stride = READ_DATA( sizeof( int ) + 20, GLint );
-	GLint order = READ_DATA( sizeof( int ) + 24, GLint );
+	GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
+	GLdouble u1 = READ_DOUBLE(sizeof(int) + 4);
+	GLdouble u2 = READ_DOUBLE(sizeof(int) + 12);
+	GLint stride = READ_DATA(sizeof(int) + 20, GLint);
+	GLint order = READ_DATA(sizeof(int) + 24, GLint);
 
-	int n_points = READ_DATA( 0, int ) - ( sizeof(int) + 28 );
+	int n_points = READ_DATA(0, int) - (sizeof(int) + 28);
 	GLdouble *points;
 
-	if ( n_points & 0x7 )
-		crError( "crUnpackMap1d: n_points=%d, expected multiple of 8\n", n_points );
-	points = (GLdouble *) crAlloc( n_points );
-	crMemcpy( points, DATA_POINTER( sizeof(int) + 28, GLdouble ), n_points );
+	if (n_points & 0x7)
+		crError("crUnpackMap1d: n_points=%d, expected multiple of 8\n", n_points);
+	points = (GLdouble *) crAlloc(n_points);
+	crMemcpy(points, DATA_POINTER(sizeof(int) + 28, GLdouble), n_points);
 	
-	cr_unpackDispatch.Map1d( target, u1, u2, stride, order, points );
-	crFree( points );
+	cr_unpackDispatch.Map1d(target, u1, u2, stride, order, points);
+	crFree(points);
 
 	INCR_VAR_PTR();
 }
 
-void crUnpackMap1f( void  )
+void crUnpackMap1f(void)
 {
-	GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLfloat u1 = READ_DATA( sizeof( int ) + 4, GLfloat );
-	GLfloat u2 = READ_DATA( sizeof( int ) + 8, GLfloat );
-	GLint stride = READ_DATA( sizeof( int ) + 12, GLint );
-	GLint order = READ_DATA( sizeof( int ) + 16, GLint );
-	GLfloat *points = DATA_POINTER( sizeof( int ) + 20, GLfloat );
+	GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
+	GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat);
+	GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat);
+	GLint stride = READ_DATA(sizeof(int) + 12, GLint);
+	GLint order = READ_DATA(sizeof(int) + 16, GLint);
+	GLfloat *points = DATA_POINTER(sizeof(int) + 20, GLfloat);
 
-	cr_unpackDispatch.Map1f( target, u1, u2, stride, order, points );
+	cr_unpackDispatch.Map1f(target, u1, u2, stride, order, points);
 	INCR_VAR_PTR();
 }
diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c
index 32978a3..5ff2994 100644
--- a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c
+++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c
@@ -13,42 +13,42 @@
 
 void crUnpackExtendProgramParameter4dvNV(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
 	GLdouble params[4];
-	params[0] = READ_DOUBLE( 16 );
-	params[1] = READ_DOUBLE( 24 );
-	params[2] = READ_DOUBLE( 32 );
-	params[3] = READ_DOUBLE( 40 );
-	cr_unpackDispatch.ProgramParameter4dvNV( target, index, params );
+	params[0] = READ_DOUBLE(16);
+	params[1] = READ_DOUBLE(24);
+	params[2] = READ_DOUBLE(32);
+	params[3] = READ_DOUBLE(40);
+	cr_unpackDispatch.ProgramParameter4dvNV(target, index, params);
 }
 
 
 void crUnpackExtendProgramParameter4fvNV(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
 	GLfloat params[4];
-	params[0] = READ_DATA( 16, GLfloat );
-	params[1] = READ_DATA( 20, GLfloat );
-	params[2] = READ_DATA( 24, GLfloat );
-	params[3] = READ_DATA( 28, GLfloat );
-	cr_unpackDispatch.ProgramParameter4fvNV( target, index, params );
+	params[0] = READ_DATA(16, GLfloat);
+	params[1] = READ_DATA(20, GLfloat);
+	params[2] = READ_DATA(24, GLfloat);
+	params[3] = READ_DATA(28, GLfloat);
+	cr_unpackDispatch.ProgramParameter4fvNV(target, index, params);
 }
 
 
 void crUnpackExtendProgramParameters4dvNV(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
-	GLuint num = READ_DATA( 16, GLuint);
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
+	GLuint num = READ_DATA(16, GLuint);
 	GLdouble *params = (GLdouble *) crAlloc(num * 4 * sizeof(GLdouble));
 	if (params) {
 		GLuint i;
 		for (i = 0; i < 4 * num; i++) {
-			params[i] = READ_DATA( 20 + i * 8, GLdouble );
+			params[i] = READ_DATA(20 + i * 8, GLdouble);
 		}
-		cr_unpackDispatch.ProgramParameters4dvNV( target, index, num, params );
+		cr_unpackDispatch.ProgramParameters4dvNV(target, index, num, params);
 		crFree(params);
 	}
 }
@@ -56,16 +56,16 @@ void crUnpackExtendProgramParameters4dvNV(void)
 
 void crUnpackExtendProgramParameters4fvNV(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
-	GLuint num = READ_DATA( 16, GLuint);
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
+	GLuint num = READ_DATA(16, GLuint);
 	GLfloat *params = (GLfloat *) crAlloc(num * 4 * sizeof(GLfloat));
 	if (params) {
 		GLuint i;
 		for (i = 0; i < 4 * num; i++) {
-			params[i] = READ_DATA( 20 + i * 4, GLfloat );
+			params[i] = READ_DATA(20 + i * 4, GLfloat);
 		}
-		cr_unpackDispatch.ProgramParameters4fvNV( target, index, num, params );
+		cr_unpackDispatch.ProgramParameters4fvNV(target, index, num, params);
 		crFree(params);
 	}
 }
@@ -73,154 +73,154 @@ void crUnpackExtendProgramParameters4fvNV(void)
 
 void crUnpackExtendAreProgramsResidentNV(void)
 {
-	GLsizei n = READ_DATA( 8, GLsizei );
-	const GLuint *programs = DATA_POINTER( 12, const GLuint );
+	GLsizei n = READ_DATA(8, GLsizei);
+	const GLuint *programs = DATA_POINTER(12, const GLuint);
 	SET_RETURN_PTR(12 + n * sizeof(GLuint));
 	SET_WRITEBACK_PTR(20 + n * sizeof(GLuint));
-	(void) cr_unpackDispatch.AreProgramsResidentNV( n, programs, NULL );
+	(void) cr_unpackDispatch.AreProgramsResidentNV(n, programs, NULL);
 }
 
 
 void crUnpackExtendLoadProgramNV(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint id = READ_DATA( 12, GLuint );
-	GLsizei len = READ_DATA( 16, GLsizei );
-	GLvoid *program = DATA_POINTER( 20, GLvoid );
-	cr_unpackDispatch.LoadProgramNV( target, id, len, program );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint id = READ_DATA(12, GLuint);
+	GLsizei len = READ_DATA(16, GLsizei);
+	GLvoid *program = DATA_POINTER(20, GLvoid);
+	cr_unpackDispatch.LoadProgramNV(target, id, len, program);
 }
 
 
 void crUnpackExtendExecuteProgramNV(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint id = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint id = READ_DATA(12, GLuint);
 	GLfloat params[4];
-	params[0] = READ_DATA( 16, GLfloat );
-	params[1] = READ_DATA( 20, GLfloat );
-	params[2] = READ_DATA( 24, GLfloat );
-	params[3] = READ_DATA( 28, GLfloat );
-	cr_unpackDispatch.ExecuteProgramNV( target, id, params );
+	params[0] = READ_DATA(16, GLfloat);
+	params[1] = READ_DATA(20, GLfloat);
+	params[2] = READ_DATA(24, GLfloat);
+	params[3] = READ_DATA(28, GLfloat);
+	cr_unpackDispatch.ExecuteProgramNV(target, id, params);
 }
 
 void crUnpackExtendRequestResidentProgramsNV(void)
 {
-	GLsizei n = READ_DATA( 8, GLsizei );
-	crError( "RequestResidentProgramsNV needs to be special cased!" );
-	cr_unpackDispatch.RequestResidentProgramsNV( n, NULL );
+	GLsizei n = READ_DATA(8, GLsizei);
+	crError("RequestResidentProgramsNV needs to be special cased!");
+	cr_unpackDispatch.RequestResidentProgramsNV(n, NULL);
 }
 
 
 void crUnpackExtendProgramLocalParameter4fvARB(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
 	GLfloat params[4];
-	params[0] = READ_DATA( 16, GLfloat );
-	params[1] = READ_DATA( 20, GLfloat );
-	params[2] = READ_DATA( 24, GLfloat );
-	params[3] = READ_DATA( 28, GLfloat );
-	cr_unpackDispatch.ProgramLocalParameter4fvARB( target, index, params );
+	params[0] = READ_DATA(16, GLfloat);
+	params[1] = READ_DATA(20, GLfloat);
+	params[2] = READ_DATA(24, GLfloat);
+	params[3] = READ_DATA(28, GLfloat);
+	cr_unpackDispatch.ProgramLocalParameter4fvARB(target, index, params);
 }
 
 
 void crUnpackExtendProgramLocalParameter4dvARB(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
 	GLdouble params[4];
-	params[0] = READ_DOUBLE( 16 );
-	params[1] = READ_DOUBLE( 24 );
-	params[2] = READ_DOUBLE( 32 );
-	params[3] = READ_DOUBLE( 40 );
-	cr_unpackDispatch.ProgramLocalParameter4dvARB( target, index, params );
+	params[0] = READ_DOUBLE(16);
+	params[1] = READ_DOUBLE(24);
+	params[2] = READ_DOUBLE(32);
+	params[3] = READ_DOUBLE(40);
+	cr_unpackDispatch.ProgramLocalParameter4dvARB(target, index, params);
 }
 
 
 
 void crUnpackExtendProgramNamedParameter4dvNV(void)
 {
-	GLuint id = READ_DATA( 8, GLuint );
-	GLsizei len = READ_DATA( 12, GLsizei );
+	GLuint id = READ_DATA(8, GLuint);
+	GLsizei len = READ_DATA(12, GLsizei);
 	GLdouble params[4];
-	GLubyte *name = crAlloc( len );
-	params[0] = READ_DOUBLE( 16 );
-	params[1] = READ_DOUBLE( 24 );
-	params[2] = READ_DOUBLE( 32 );
-	params[3] = READ_DOUBLE( 40 );
-	crMemcpy( name, DATA_POINTER( 48, GLubyte ), len );
-	cr_unpackDispatch.ProgramNamedParameter4dvNV( id, len, name, params );
+	GLubyte *name = crAlloc(len);
+	params[0] = READ_DOUBLE(16);
+	params[1] = READ_DOUBLE(24);
+	params[2] = READ_DOUBLE(32);
+	params[3] = READ_DOUBLE(40);
+	crMemcpy(name, DATA_POINTER(48, GLubyte), len);
+	cr_unpackDispatch.ProgramNamedParameter4dvNV(id, len, name, params);
 }
 
 void crUnpackExtendProgramNamedParameter4dNV(void)
 {
-	GLuint id = READ_DATA( 8, GLuint );
-	GLsizei len = READ_DATA( 12, GLsizei );
+	GLuint id = READ_DATA(8, GLuint);
+	GLsizei len = READ_DATA(12, GLsizei);
 	GLdouble params[4];
-	GLubyte *name = crAlloc ( len );
-	params[0] = READ_DOUBLE( 16 );
-	params[1] = READ_DOUBLE( 24 );
-	params[2] = READ_DOUBLE( 32 );
-	params[3] = READ_DOUBLE( 40 );
-	crMemcpy( name, DATA_POINTER( 48, GLubyte ), len );
-	cr_unpackDispatch.ProgramNamedParameter4dNV( id, len, name, params[0], params[1], params[2], params[3] );
+	GLubyte *name = crAlloc (len);
+	params[0] = READ_DOUBLE(16);
+	params[1] = READ_DOUBLE(24);
+	params[2] = READ_DOUBLE(32);
+	params[3] = READ_DOUBLE(40);
+	crMemcpy(name, DATA_POINTER(48, GLubyte), len);
+	cr_unpackDispatch.ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]);
 }
 
 void crUnpackExtendProgramNamedParameter4fNV(void)
 {
-	GLenum id = READ_DATA( 8, GLuint );
-	GLsizei len = READ_DATA( 12, GLsizei );
+	GLenum id = READ_DATA(8, GLuint);
+	GLsizei len = READ_DATA(12, GLsizei);
 	GLfloat params[4];
-	GLubyte *name = crAlloc( len);
-	params[0] = READ_DATA( 16, GLfloat );
-	params[1] = READ_DATA( 20, GLfloat );
-	params[2] = READ_DATA( 24, GLfloat );
-	params[3] = READ_DATA( 28, GLfloat );
-	crMemcpy( name, DATA_POINTER( 32,  GLubyte ), len );
-	cr_unpackDispatch.ProgramNamedParameter4fNV( id, len, name, params[0], params[1], params[2], params[3] );
+	GLubyte *name = crAlloc(len);
+	params[0] = READ_DATA(16, GLfloat);
+	params[1] = READ_DATA(20, GLfloat);
+	params[2] = READ_DATA(24, GLfloat);
+	params[3] = READ_DATA(28, GLfloat);
+	crMemcpy(name, DATA_POINTER(32,  GLubyte), len);
+	cr_unpackDispatch.ProgramNamedParameter4fNV(id, len, name, params[0], params[1], params[2], params[3]);
 }
 
 void crUnpackExtendProgramNamedParameter4fvNV(void)
 {
-	GLenum id = READ_DATA( 8, GLuint );
-	GLsizei len = READ_DATA( 12, GLsizei );
+	GLenum id = READ_DATA(8, GLuint);
+	GLsizei len = READ_DATA(12, GLsizei);
 	GLfloat params[4];
-	GLubyte *name = crAlloc( len);
-	params[0] = READ_DATA( 16, GLfloat );
-	params[1] = READ_DATA( 20, GLfloat );
-	params[2] = READ_DATA( 24, GLfloat );
-	params[3] = READ_DATA( 28, GLfloat );
-	crMemcpy( name, DATA_POINTER( 32, GLubyte ), len );
-	cr_unpackDispatch.ProgramNamedParameter4fvNV( id, len, name, params );
+	GLubyte *name = crAlloc(len);
+	params[0] = READ_DATA(16, GLfloat);
+	params[1] = READ_DATA(20, GLfloat);
+	params[2] = READ_DATA(24, GLfloat);
+	params[3] = READ_DATA(28, GLfloat);
+	crMemcpy(name, DATA_POINTER(32, GLubyte), len);
+	cr_unpackDispatch.ProgramNamedParameter4fvNV(id, len, name, params);
 }
 
 void crUnpackExtendGetProgramNamedParameterdvNV(void)
 {
-	GLuint id = READ_DATA( 8, GLuint );
-	GLsizei len = READ_DATA( 12, GLsizei );
-	const GLubyte *name = DATA_POINTER( 16, GLubyte );
-	SET_RETURN_PTR( 16+len );
-	SET_WRITEBACK_PTR( 16+len+8 );
-	cr_unpackDispatch.GetProgramNamedParameterdvNV( id, len, name, NULL );
+	GLuint id = READ_DATA(8, GLuint);
+	GLsizei len = READ_DATA(12, GLsizei);
+	const GLubyte *name = DATA_POINTER(16, GLubyte);
+	SET_RETURN_PTR(16+len);
+	SET_WRITEBACK_PTR(16+len+8);
+	cr_unpackDispatch.GetProgramNamedParameterdvNV(id, len, name, NULL);
 }
 
 void crUnpackExtendGetProgramNamedParameterfvNV(void)
 {
-	GLuint id = READ_DATA( 8, GLuint );
-	GLsizei len = READ_DATA( 12, GLsizei );
-	const GLubyte *name = DATA_POINTER( 16, GLubyte );
-	SET_RETURN_PTR( 16+len );
-	SET_WRITEBACK_PTR( 16+len+8 );
-	cr_unpackDispatch.GetProgramNamedParameterfvNV( id, len, name, NULL );
+	GLuint id = READ_DATA(8, GLuint);
+	GLsizei len = READ_DATA(12, GLsizei);
+	const GLubyte *name = DATA_POINTER(16, GLubyte);
+	SET_RETURN_PTR(16+len);
+	SET_WRITEBACK_PTR(16+len+8);
+	cr_unpackDispatch.GetProgramNamedParameterfvNV(id, len, name, NULL);
 }
 
 void crUnpackExtendProgramStringARB(void)
 { 
-      GLenum target = READ_DATA( 8, GLenum );
-      GLenum format = READ_DATA( 12, GLuint );
-      GLsizei len = READ_DATA( 16, GLsizei );
-      GLvoid *program = DATA_POINTER( 20, GLvoid );
-      cr_unpackDispatch.ProgramStringARB( target, format, len, program );
+      GLenum target = READ_DATA(8, GLenum);
+      GLenum format = READ_DATA(12, GLuint);
+      GLsizei len = READ_DATA(16, GLsizei);
+      GLvoid *program = DATA_POINTER(20, GLvoid);
+      cr_unpackDispatch.ProgramStringARB(target, format, len, program);
 }
 
 void crUnpackExtendGetProgramStringARB(void)
@@ -229,119 +229,119 @@ void crUnpackExtendGetProgramStringARB(void)
 
 void crUnpackExtendProgramEnvParameter4dvARB(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
 	GLdouble params[4];
-	params[0] = READ_DOUBLE( 16 );
-	params[1] = READ_DOUBLE( 24 );
-	params[2] = READ_DOUBLE( 32 );
-	params[3] = READ_DOUBLE( 40 );
-	cr_unpackDispatch.ProgramEnvParameter4dvARB( target, index, params );
+	params[0] = READ_DOUBLE(16);
+	params[1] = READ_DOUBLE(24);
+	params[2] = READ_DOUBLE(32);
+	params[3] = READ_DOUBLE(40);
+	cr_unpackDispatch.ProgramEnvParameter4dvARB(target, index, params);
 }
 
 void crUnpackExtendProgramEnvParameter4fvARB(void)
 {
-	GLenum target = READ_DATA( 8, GLenum );
-	GLuint index = READ_DATA( 12, GLuint );
+	GLenum target = READ_DATA(8, GLenum);
+	GLuint index = READ_DATA(12, GLuint);
 	GLfloat params[4];
-	params[0] = READ_DATA( 16, GLfloat );
-	params[1] = READ_DATA( 20, GLfloat );
-	params[2] = READ_DATA( 24, GLfloat );
-	params[3] = READ_DATA( 28, GLfloat );
-	cr_unpackDispatch.ProgramEnvParameter4fvARB( target, index, params );
+	params[0] = READ_DATA(16, GLfloat);
+	params[1] = READ_DATA(20, GLfloat);
+	params[2] = READ_DATA(24, GLfloat);
+	params[3] = READ_DATA(28, GLfloat);
+	cr_unpackDispatch.ProgramEnvParameter4fvARB(target, index, params);
 }
 
 void crUnpackExtendDeleteProgramsARB(void)
 {
-	GLsizei n = READ_DATA( 8, GLsizei );
-	const GLuint *programs = DATA_POINTER( 12, GLuint );
-	cr_unpackDispatch.DeleteProgramsARB( n, programs );
+	GLsizei n = READ_DATA(8, GLsizei);
+	const GLuint *programs = DATA_POINTER(12, GLuint);
+	cr_unpackDispatch.DeleteProgramsARB(n, programs);
 }
 
 void crUnpackVertexAttrib4NbvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLbyte *v = DATA_POINTER(4, const GLbyte);
-	cr_unpackDispatch.VertexAttrib4NbvARB( index, v );
-	INCR_DATA_PTR( 8 );
+	cr_unpackDispatch.VertexAttrib4NbvARB(index, v);
+	INCR_DATA_PTR(8);
 }
 
 void crUnpackVertexAttrib4NivARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLint *v = DATA_POINTER(4, const GLint);
-	cr_unpackDispatch.VertexAttrib4NivARB( index, v );
-	INCR_DATA_PTR( 20 );
+	cr_unpackDispatch.VertexAttrib4NivARB(index, v);
+	INCR_DATA_PTR(20);
 }
 
 void crUnpackVertexAttrib4NsvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLshort *v = DATA_POINTER(4, const GLshort);
-	cr_unpackDispatch.VertexAttrib4NsvARB( index, v );
-	INCR_DATA_PTR( 12 );
+	cr_unpackDispatch.VertexAttrib4NsvARB(index, v);
+	INCR_DATA_PTR(12);
 }
 
 void crUnpackVertexAttrib4NubvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLubyte *v = DATA_POINTER(4, const GLubyte);
-	cr_unpackDispatch.VertexAttrib4NubvARB( index, v );
-	INCR_DATA_PTR( 8 );
+	cr_unpackDispatch.VertexAttrib4NubvARB(index, v);
+	INCR_DATA_PTR(8);
 }
 
 void crUnpackVertexAttrib4NuivARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLuint *v = DATA_POINTER(4, const GLuint);
-	cr_unpackDispatch.VertexAttrib4NuivARB( index, v );
-	INCR_DATA_PTR( 20 );
+	cr_unpackDispatch.VertexAttrib4NuivARB(index, v);
+	INCR_DATA_PTR(20);
 }
 
 void crUnpackVertexAttrib4NusvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLushort *v = DATA_POINTER(4, const GLushort);
-	cr_unpackDispatch.VertexAttrib4NusvARB( index, v );
-	INCR_DATA_PTR( 12 );
+	cr_unpackDispatch.VertexAttrib4NusvARB(index, v);
+	INCR_DATA_PTR(12);
 }
 
 void crUnpackVertexAttrib4bvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLbyte *v = DATA_POINTER(4, const GLbyte);
-	cr_unpackDispatch.VertexAttrib4bvARB( index, v );
-	INCR_DATA_PTR( 8 );
+	cr_unpackDispatch.VertexAttrib4bvARB(index, v);
+	INCR_DATA_PTR(8);
 }
 
 void crUnpackVertexAttrib4ivARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLint *v = DATA_POINTER(4, const GLint);
-	cr_unpackDispatch.VertexAttrib4ivARB( index, v );
-	INCR_DATA_PTR( 20 );
+	cr_unpackDispatch.VertexAttrib4ivARB(index, v);
+	INCR_DATA_PTR(20);
 }
 
 void crUnpackVertexAttrib4ubvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLubyte *v = DATA_POINTER(4, const GLubyte);
-	cr_unpackDispatch.VertexAttrib4ubvARB( index, v );
-	INCR_DATA_PTR( 8 );
+	cr_unpackDispatch.VertexAttrib4ubvARB(index, v);
+	INCR_DATA_PTR(8);
 }
 
 void crUnpackVertexAttrib4uivARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLuint *v = DATA_POINTER(4, const GLuint);
-	cr_unpackDispatch.VertexAttrib4uivARB( index, v );
-	INCR_DATA_PTR( 20 );
+	cr_unpackDispatch.VertexAttrib4uivARB(index, v);
+	INCR_DATA_PTR(20);
 }
 
 void crUnpackVertexAttrib4usvARB(void)
 {
-	GLuint index = READ_DATA( 0, GLuint );
+	GLuint index = READ_DATA(0, GLuint);
 	const GLushort *v = DATA_POINTER(4, const GLushort);
-	cr_unpackDispatch.VertexAttrib4usvARB( index, v );
-	INCR_DATA_PTR( 12 );
+	cr_unpackDispatch.VertexAttrib4usvARB(index, v);
+	INCR_DATA_PTR(12);
 }
diff --git a/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
index 9e6cb79..06d6138 100644
--- a/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
+++ b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
@@ -16,6 +16,7 @@
 
 %define %SPEC% 1
 %define %OSE% 1
+%define %PYTHON% 1
 %define VBOXDOCDIR %{_defaultdocdir}/%NAME%
 %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
 
@@ -76,9 +77,11 @@ install -m 755 -d $RPM_BUILD_ROOT%{VBOXDOCDIR}
 install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
 install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
 install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
+%if %{?with_python:1}%{!?with_python:0}
 (export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
   cd ./sdk/installer && \
   %{__python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
+%endif
 rm -rf sdk/installer
 mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
 cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
@@ -302,8 +305,10 @@ rm -rf $RPM_BUILD_ROOT
 %files
 %defattr(-,root,root)
 %doc %{VBOXDOCDIR}/*
+%if %{?with_python:1}%{!?with_python:0}
 %{?rpm_suse: %{py_sitedir}/*}
 %{!?rpm_suse: %{python_sitelib}/*}
+%endif
 /etc/vbox
 /usr/bin/*
 /usr/src/vbox*
diff --git a/src/VBox/Installer/linux/rpm/rules b/src/VBox/Installer/linux/rpm/rules
index 046b6e9..d144026 100755
--- a/src/VBox/Installer/linux/rpm/rules
+++ b/src/VBox/Installer/linux/rpm/rules
@@ -31,7 +31,6 @@
 #  NOWEBSVC=1       don't build the webservice API, default for OSE
 #  STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
 #  PKGDIR=<path>    where to store the final package(s)
-#  BLEEDING_EDGE=xyz
 #  svn_revision=xxx do not depend on subversion being available, but use this
 #                   hard-coded revision number instead
 #
@@ -80,22 +79,22 @@ STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vbox
 NOWINE   := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
 
 ifneq ($(MAKECMDGOALS),clean)
- rpmrel   := $(subst ol,el,$(subst rhel,el,$(shell cat /etc/distname)))
+ rpmrel   := $(subst ol,el,$(subst rhel,el,$(subst centos,el,$(shell cat /etc/distname))))
  ifeq ($(rpmrel),)
  # look for fedora
   rpmrel  := $(shell cat /etc/fedora-release 2> /dev/null | sed -e 's/^Fedora  *release  *\([1-9][0-9]*\) .*/fedora\1/')
  endif
  ifeq ($(rpmrel),)
  # look for OL
-  rpmrel  := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/ol\1/p')
+  rpmrel  := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
  endif
  ifeq ($(rpmrel),)
  # look for CentOS
-  rpmrel  := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/centos\1/p')
+  rpmrel  := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
  endif
  ifeq ($(rpmrel),)
  # look for Red Hat
-  rpmrel  := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/centos\1/p')
+  rpmrel  := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
  endif
  ifeq ($(rpmrel),)
   $(error failed to detect the release type. Add /etc/distname or hack the detection.)
@@ -106,15 +105,12 @@ ifneq ($(MAKECMDGOALS),clean)
   $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
  endif
 
- ifeq ($(filter-out el5 el6 ol5 ol6 el7 centos5 centos6 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24,$(rpmrel)),)
+ ifeq ($(filter-out el5 el6 el7 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24,$(rpmrel)),)
   rpmspec := rpm_redhat
  endif
- ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 sles10.1 sles11.0,$(rpmrel)),)
+ ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132,$(rpmrel)),)
   rpmspec := rpm_suse
  endif
- ifeq ($(filter-out mdv2009.1 mdv2010.0 mdv2011.0,$(rpmrel)),)
-  rpmspec := rpm_mdv
- endif
  ifeq ($(rpmspec),)
   $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
  endif
@@ -127,7 +123,7 @@ $(verfile): rpm/configure-stamp
 endif
 
 ver      := $(VBOX_VERSION_STRING)
-rpmver   :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
+rpmver   :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))
 archdir  := $(current)/rpm/VirtualBox-$(ver)
 rpmname  := $(verpkg)-$(rpmver)_$(rpmrel)
 
@@ -149,11 +145,11 @@ endif
 
 cfg_flags := $(if $(NOQT),--disable-qt,) \
 	     $(if $(NOSDL),--disable-vboxsdl,) \
-	     $(if $(filter sles10.1,$(rpmrel)),--build-libxml2,) \
-	     $(if $(filter el5 ol5 centos5 el6 ol6 centos6 sles10.1 sles11.0 mdv2011.0,$(rpmrel)),--build-libvpx,) \
-	     $(if $(filter el5 ol5 centos5 sles10.1 sles11.0,$(rpmrel)),--build-libcurl,) \
-	     $(if $(filter el5 ol5 centos5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
-	     $(if $(filter el5 ol5 centos5 sles10.1,$(rpmrel)),--disable-pulse,) \
+	     $(if $(filter el5 el6,$(rpmrel)),--build-libvpx,) \
+	     $(if $(filter el5,$(rpmrel)),--build-libcurl,) \
+	     $(if $(filter el5,$(rpmrel)),--disable-sdl-ttf,) \
+	     $(if $(filter el5,$(rpmrel)),--disable-pulse,) \
+	     $(if $(filter el5,$(rpmrel)),--disable-python,) \
 	     $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
 	     $(if $(HEADLESS),--build-headless,) \
 	     $(if $(DEBUG),--build-debug,) \
@@ -167,9 +163,10 @@ bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
 	     PATH_OUT=$(builddir) \
 	     VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
 	     VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
-	     $(if $(filter el5 ol5 centos5 el6 ol6 centos6 sles10.1 sles11.0,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
+	     $(if $(filter el5 el6,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
 	     VBOX_DO_STRIP= \
-	     $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=/usr/bin/python,) \
+	     $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=$(strip \
+		$(firstword $(wildcard /usr/local/bin/python2.7) $(wildcard /usr/bin/python))),) \
 	     VBOX_WITH_MULTIVERSION_PYTHON= \
 	     $(doc_dir) \
 	     $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
@@ -178,8 +175,7 @@ bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
 	     $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
 	     $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
 	     $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
-	     $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
-	     $(if $(filter el5 ol5 centos5 sles10.1,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
+	     $(if $(filter el5,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
 
 rpm/configure-stamp:
 	cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
@@ -227,6 +223,7 @@ binary: rpm/build-stamp
 	    -e 's|%LIB%|$(rpmlib)|g' \
 	    -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
 	    -e 's|%SPEC%|$(rpmspec)|g' \
+	    -e 's|%PYTHON%|$(if $(filter el5,$(rpmrel)),,with_python)|g' \
 	    -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
 	    -e 's|%INSTMOD%|$(instmod)|g' \
 	    -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
diff --git a/src/VBox/Installer/win/NLS/de_DE.wxl b/src/VBox/Installer/win/NLS/de_DE.wxl
index 909e535..cbc52b2 100644
--- a/src/VBox/Installer/win/NLS/de_DE.wxl
+++ b/src/VBox/Installer/win/NLS/de_DE.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -119,7 +119,8 @@
 
     <String Id="Customize2Dlg_Header">Anpassen</String>
     <String Id="Customize2Dlg_Desc">Bitte unten die gewünschten Optionen auswählen:</String>
-    <String Id="Customize2Dlg_CreateShortcut">Verknüpfung auf dem Desktop anlegen</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Startmenü-Einträge anlegen</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">Verknüpfung auf dem Desktop anlegen</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">Verknüpfung in der Schnellstartleiste anlegen</String>
     <String Id="Customize2Dlg_RegisterFileExtensions">Dateizuordnungen registrieren</String>
 
diff --git a/src/VBox/Installer/win/NLS/en_US.wxl b/src/VBox/Installer/win/NLS/en_US.wxl
index a1cfd86..fa3d8e6 100644
--- a/src/VBox/Installer/win/NLS/en_US.wxl
+++ b/src/VBox/Installer/win/NLS/en_US.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -123,7 +123,8 @@
 
     <String Id="Customize2Dlg_Header">Customize</String>
     <String Id="Customize2Dlg_Desc">Please choose from the options below:</String>
-    <String Id="Customize2Dlg_CreateShortcut">Create a shortcut on the desktop</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Create start menu entries</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">Create a shortcut on the desktop</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">Create a shortcut in the Quick Launch Bar</String>
     <String Id="Customize2Dlg_RegisterFileExtensions">Register file associations</String>
 
diff --git a/src/VBox/Installer/win/NLS/fa_IR.wxl b/src/VBox/Installer/win/NLS/fa_IR.wxl
index ca8b2cc..91f9950 100644
--- a/src/VBox/Installer/win/NLS/fa_IR.wxl
+++ b/src/VBox/Installer/win/NLS/fa_IR.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -96,7 +96,8 @@
     <!---->
     <String Id="Customize2Dlg_Header">سفارشی</String>
     <String Id="Customize2Dlg_Desc">لطفاً از گزینه های زیر انتخاب کنید:</String>
-    <String Id="Customize2Dlg_CreateShortcut">ایجاد یک میانبر روی دسکتاپ</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Create start menu entries</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">ایجاد یک میانبر روی دسکتاپ</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">ایجاد یک میانبر در اِجرای سریع</String>
     <String Id="Customize2Dlg_RegisterFileExtensions">ثبت نام انجمن فایل</String>
     <!---->
diff --git a/src/VBox/Installer/win/NLS/fr_FR.wxl b/src/VBox/Installer/win/NLS/fr_FR.wxl
index 011564c..bbdd78f 100644
--- a/src/VBox/Installer/win/NLS/fr_FR.wxl
+++ b/src/VBox/Installer/win/NLS/fr_FR.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -115,10 +115,11 @@
     <String Id="CustomizeDlg_SelItemPath"><Chemin de l'entrée sélectionnée></String>
 
     <!---->
-  
+
     <String Id="Customize2Dlg_Header">Personaliser</String>
     <String Id="Customize2Dlg_Desc">Veuillez choisir une des options suivantes:</String>
-    <String Id="Customize2Dlg_CreateShortcut">Créer un raccourci sur le bureau</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Créer des éléments dans le menu démarrer</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">Créer un raccourci sur le bureau</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">Créer un raccourci dans la barre de lancement rapide</String>
     <String Id="Customize2Dlg_RegisterFileExtensions">Inscription des associations de fichiers</String>
 
diff --git a/src/VBox/Installer/win/NLS/it_IT.wxl b/src/VBox/Installer/win/NLS/it_IT.wxl
index 79b72aa..5d0b4c5 100644
--- a/src/VBox/Installer/win/NLS/it_IT.wxl
+++ b/src/VBox/Installer/win/NLS/it_IT.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -96,7 +96,8 @@
     <!---->
     <String Id="Customize2Dlg_Header">Personalizza</String>
     <String Id="Customize2Dlg_Desc">Scegli dalle opzioni seguenti:</String>
-    <String Id="Customize2Dlg_CreateShortcut">Crea una scorciatoia sul desktop</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Create start menu entries</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">Crea una scorciatoia sul desktop</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">Crea una scorciatoia nella barra di avvio veloce</String>
     <String Id="Customize2Dlg_RegisterFileExtensions">Registrati associazioni di file</String>
     <!---->
diff --git a/src/VBox/Installer/win/NLS/tr_TR.wxl b/src/VBox/Installer/win/NLS/tr_TR.wxl
index 7cfd0d0..4cf5c83 100644
--- a/src/VBox/Installer/win/NLS/tr_TR.wxl
+++ b/src/VBox/Installer/win/NLS/tr_TR.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -123,7 +123,8 @@
 
 	<String Id="Customize2Dlg_Header">Özelleştir</String>
     <String Id="Customize2Dlg_Desc">Lütfen aşağıdaki seçeneklerden seçin:</String>
-    <String Id="Customize2Dlg_CreateShortcut">Masaüstüne kısayol oluştur</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Create start menu entries</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">Masaüstüne kısayol oluştur</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">Hızlı Başlat Çubuğuna kısayol oluştur</String>
 
 	<!---->
diff --git a/src/VBox/Installer/win/NLS/zh_TW.wxl b/src/VBox/Installer/win/NLS/zh_TW.wxl
index 81b4619..9fb3a55 100644
--- a/src/VBox/Installer/win/NLS/zh_TW.wxl
+++ b/src/VBox/Installer/win/NLS/zh_TW.wxl
@@ -4,7 +4,7 @@
     <!--
             Language Definition Include for VirtualBox WiX script.
 
-            Copyright (C) 2011-2015 Oracle Corporation
+            Copyright (C) 2011-2016 Oracle Corporation
 
             This file is part of VirtualBox Open Source Edition (OSE), as
             available from http://www.virtualbox.org. This file is free software;
@@ -123,7 +123,8 @@
 
     <String Id="Customize2Dlg_Header">自訂</String>
     <String Id="Customize2Dlg_Desc">請選擇以下選項:</String>
-    <String Id="Customize2Dlg_CreateShortcut">在桌面建立捷徑</String>
+    <String Id="Customize2Dlg_CreateStartMenuEntries">Create start menu entries</String>
+    <String Id="Customize2Dlg_CreateDesktopShortcut">在桌面建立捷徑</String>
     <String Id="Customize2Dlg_CreateQuickLaunch">在快速啟動列建立捷徑</String>
     <String Id="Customize2Dlg_RegisterFileExtensions">註冊文件關聯</String>
 
diff --git a/src/VBox/Installer/win/PublicProperties.wxi b/src/VBox/Installer/win/PublicProperties.wxi
index f6e9c01..b5acad7 100644
--- a/src/VBox/Installer/win/PublicProperties.wxi
+++ b/src/VBox/Installer/win/PublicProperties.wxi
@@ -24,6 +24,11 @@
   <SetProperty Id="VBOX_INSTALLDESKTOPSHORTCUT" After="AppSearch" Sequence="both"
                Value="{}"><![CDATA[VBOX_INSTALLDESKTOPSHORTCUT="0"]]></SetProperty>
 
+  <!-- Whether or not start menu entries should be created. -->
+  <Property Id="VBOX_INSTALLSTARTMENUENTRIES" Value="1" Secure="yes"/>
+  <SetProperty Id="VBOX_INSTALLSTARTMENUENTRIES" After="AppSearch" Sequence="both"
+               Value="{}"><![CDATA[VBOX_INSTALLSTARTMENUENTRIES="0"]]></SetProperty>
+
   <!-- Whether or not a desktop shortcut for the Quick Launch Bar should be created -->
   <Property Id="VBOX_INSTALLQUICKLAUNCHSHORTCUT" Value="1" Secure="yes"/>
   <SetProperty Id="VBOX_INSTALLQUICKLAUNCHSHORTCUT" After="AppSearch" Sequence="both"
diff --git a/src/VBox/Installer/win/UserInterface.wxi b/src/VBox/Installer/win/UserInterface.wxi
index 485142f..c626e89 100644
--- a/src/VBox/Installer/win/UserInterface.wxi
+++ b/src/VBox/Installer/win/UserInterface.wxi
@@ -392,15 +392,19 @@
                  of Windows that use other default background colors, and on the machines of users that
                  change their Windows color scheme.
                  Also see: http://osdir.com/ml/windows.devel.wix.user/2005-02/msg00300.html -->
-            <Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="25" Y="95" Width="200" Height="17"
+            <Control Id="StartMenuEntriesCheckBox" Type="CheckBox" X="25" Y="95" Width="200" Height="17"
+                     Property="VBOX_INSTALLSTARTMENUENTRIES" CheckBoxValue="1" Default="no">
+                <Text>!(loc.Customize2Dlg_CreateStartMenuEntries)</Text>
+            </Control>
+            <Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="25" Y="115" Width="200" Height="17"
                      Property="VBOX_INSTALLDESKTOPSHORTCUT" CheckBoxValue="1" Default="no">
-                <Text>!(loc.Customize2Dlg_CreateShortcut)</Text>
+                <Text>!(loc.Customize2Dlg_CreateDesktopShortcut)</Text>
             </Control>
-            <Control Id="QuicklaunchShortcutCheckBox" Type="CheckBox" X="25" Y="115" Width="200" Height="17"
+            <Control Id="QuicklaunchShortcutCheckBox" Type="CheckBox" X="25" Y="135" Width="200" Height="17"
                      Property="VBOX_INSTALLQUICKLAUNCHSHORTCUT" CheckBoxValue="1" Default="no">
                 <Text>!(loc.Customize2Dlg_CreateQuickLaunch)</Text>
             </Control>
-            <Control Id="RegisterFileExtensionsCheckBox" Type="CheckBox" X="25" Y="135" Width="200" Height="17"
+            <Control Id="RegisterFileExtensionsCheckBox" Type="CheckBox" X="25" Y="155" Width="200" Height="17"
                      Property="VBOX_REGISTERFILEEXTENSIONS" CheckBoxValue="1" Default="no">
                 <Text>!(loc.Customize2Dlg_RegisterFileExtensions)</Text>
             </Control>
diff --git a/src/VBox/Installer/win/VirtualBox.wxs b/src/VBox/Installer/win/VirtualBox.wxs
index cd61075..e6b2300 100644
--- a/src/VBox/Installer/win/VirtualBox.wxs
+++ b/src/VBox/Installer/win/VirtualBox.wxs
@@ -2,7 +2,7 @@
 <!--
     VirtualBox Windows Installation Script (WiX)
 
-    Copyright (C) 2014-2015 Oracle Corporation
+    Copyright (C) 2014-2016 Oracle Corporation
 
     This file is part of VirtualBox Open Source Edition (OSE), as
     available from http://www.virtualbox.org. This file is free software;
@@ -60,7 +60,7 @@
     <Property Id="ARPPRODUCTICON">IconVirtualBox</Property>
     <Property Id="ARPURLINFOABOUT">http://www.virtualbox.org</Property>
     <Property Id="ARPURLUPDATEINFO">http://www.virtualbox.org</Property>
-    
+
     <Property Id="NETWORKTYPE" Value="NDIS6" Secure="yes"/>
 
 <?if $(env.VBOX_WITH_MSM_INSTALL) = "no" ?>
@@ -230,7 +230,7 @@
                 <Directory Id="INSTALLDIR" Name="VirtualBox">
 <?if $(env.VBOX_WITH_MSM_INSTALL) = "yes" ?>
                 <Merge Id="msm_VBoxApp" Language="!(loc.LANG)" SourceFile="$(var.Property_VBoxMergeApp)" DiskId="1">
-                    <ConfigurationData Name="argRegesterExtensions" Value="[VBOX_REGISTERFILEEXTENSIONS]"/> 
+                    <ConfigurationData Name="argRegesterExtensions" Value="[VBOX_REGISTERFILEEXTENSIONS]"/>
                 </Merge>
     <?if $(env.VBOX_WITH_32_ON_64_MAIN_API) = "yes" ?>
                 <Merge Id="msm_VBoxCOM32On64" Language="!(loc.LANG)" SourceFile="$(var.Property_VBoxMergeCOM32On64)" DiskId="1" />
@@ -258,7 +258,7 @@
                         <Directory Id="dir_NetFlt" Name="netflt">
     <?if $(env.VBOX_WITH_MSM_INSTALL) = "yes" ?>
                             <Merge Id="msm_VBoxNetworkFlt" Language="!(loc.LANG)" SourceFile="$(var.Property_VBoxMergeNetworkFlt)" DiskId="1">
-                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/> 
+                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/>
                             </Merge>
     <?else ?>
                             <Directory Id="msm_VBoxNetworkFltFolder" FileSource=".">
@@ -270,7 +270,7 @@
                         <Directory Id="dir_NetAdp" Name="netadp">
 <?if $(env.VBOX_WITH_MSM_INSTALL) = "yes" ?>
                             <Merge Id="msm_VBoxNetworkAdp" Language="!(loc.LANG)" SourceFile="$(var.Property_VBoxMergeNetworkAdp)" DiskId="1">
-                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/> 
+                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/>
                             </Merge>
 <?else ?>
                             <Directory Id="msm_VBoxNetworkAdpFolder" FileSource=".">
@@ -283,7 +283,7 @@
                         <Directory Id="dir_NetLwf" Name="netlwf">
     <?if $(env.VBOX_WITH_MSM_INSTALL) = "yes" ?>
                             <Merge Id="msm_VBoxNetworkLwf" Language="!(loc.LANG)" SourceFile="$(var.Property_VBoxMergeNetworkLwf)" DiskId="1">
-                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/> 
+                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/>
                             </Merge>
     <?else ?>
                             <Directory Id="msm_VBoxNetworkLwfFolder" FileSource=".">
@@ -295,7 +295,7 @@
                         <Directory Id="dir_NetAdp6" Name="netadp6">
 <?if $(env.VBOX_WITH_MSM_INSTALL) = "yes" ?>
                             <Merge Id="msm_VBoxNetworkAdp6" Language="!(loc.LANG)" SourceFile="$(var.Property_VBoxMergeNetworkAdp6)" DiskId="1">
-                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/> 
+                            <ConfigurationData Name="passedNetworkType" Value="[NETWORKTYPE]"/>
                             </Merge>
 <?else ?>
                             <Directory Id="msm_VBoxNetworkAdp6Folder" FileSource=".">
@@ -336,8 +336,9 @@
                     </Directory>
                 </Directory>
 
-                <!-- Shortcut(s) in start menu -->
+                <!-- Start menu entries. -->
                 <Component Id="cp_StartMenuVBox" Guid="C2DC321A-CE63-40EE-8A98-724DF8BD12FB" Win64="$(var.Property_Win64)">
+                    <Condition>VBOX_INSTALLSTARTMENUENTRIES</Condition>
                     <Shortcut Id="sc_StartMenuVBox" Directory="dir_StartMenuVBox" Name="$(env.VBOX_PRODUCT)" Description="$(env.VBOX_PRODUCT)"
                               Target="[INSTALLDIR]VirtualBox.exe" WorkingDirectory="INSTALLDIR"/>
                     <RegistryValue Root="HKCU" Key="$(var.Property_RegKeyInstall)"
@@ -345,6 +346,7 @@
                     <?include $(env.PATH_TARGET)\Shortcuts_StartMenu.wxi ?>
                 </Component>
 
+                <!-- Desktop shortcut. -->
                 <Component Id="cp_DesktopShortcut" Guid="668F8A1A-F5CE-48B3-BB1A-3042EE27B279" Win64="$(var.Property_Win64)">
                     <Condition>VBOX_INSTALLDESKTOPSHORTCUT</Condition>
                     <Shortcut Id="sc_DesktopVBox" Directory="DesktopFolder" Name="$(env.VBOX_PRODUCT)" Description="$(env.VBOX_PRODUCT)"
@@ -353,6 +355,7 @@
                                    Value="installed" KeyPath="yes" />
                 </Component>
 
+                <!-- QuickLaunch shortcut. -->
                 <Component Id="cp_QuickLaunchVBox" Guid="CC19E026-938A-41CB-8E77-3F33296244B6" Win64="$(var.Property_Win64)">
                     <CreateFolder/>
                     <Condition>VBOX_INSTALLQUICKLAUNCHSHORTCUT</Condition>
diff --git a/src/VBox/Main/Makefile.kmk b/src/VBox/Main/Makefile.kmk
index ecdbcdc..de792dd 100644
--- a/src/VBox/Main/Makefile.kmk
+++ b/src/VBox/Main/Makefile.kmk
@@ -327,7 +327,7 @@ VBoxSVC_LIBS += \
 	$(PATH_STAGE_LIB)/SSMStandalone$(VBOX_SUFF_LIB) \
 	$(LIB_DDU)
 
-VBoxSVC_SDKS = VBOX_LIBPNG VBOX_ZLIB VBOX_OPENSSL
+VBoxSVC_SDKS = VBOX_LIBPNG VBOX_ZLIB
 VBoxSVC_LIBS.solaris = \
 	adm \
 	nsl \
diff --git a/src/VBox/Main/glue/com.cpp b/src/VBox/Main/glue/com.cpp
index eecf40c..b02e365 100644
--- a/src/VBox/Main/glue/com.cpp
+++ b/src/VBox/Main/glue/com.cpp
@@ -311,8 +311,17 @@ static DECLCALLBACK(void) vboxHeaderFooter(PRTLOGGER pReleaseLogger, RTLOGPHASE
             if (RT_SUCCESS(vrc))
                 vrc = RTSystemQueryAvailableRam(&cbHostRamAvail);
             if (RT_SUCCESS(vrc))
-                pfnLog(pReleaseLogger, "Host RAM: %lluMB total, %lluMB available\n",
-                       cbHostRam / _1M, cbHostRamAvail / _1M);
+            {
+                pfnLog(pReleaseLogger, "Host RAM: %lluMB", cbHostRam / _1M);
+                if (cbHostRam > _2G)
+                    pfnLog(pReleaseLogger, " (%lld.%lldGB)",
+                           cbHostRam / _1G, (cbHostRam % _1G) / (_1G / 10));
+                pfnLog(pReleaseLogger, " total, %lluMB", cbHostRamAvail / _1M);
+                if (cbHostRamAvail > _2G)
+                    pfnLog(pReleaseLogger, " (%lld.%lldGB)",
+                           cbHostRamAvail / _1G, (cbHostRamAvail % _1G) / (_1G / 10));
+                pfnLog(pReleaseLogger, " available\n");
+            }
 
             /* the package type is interesting for Linux distributions */
             char szExecName[RTPATH_MAX];
diff --git a/src/VBox/Main/include/ThreadTask.h b/src/VBox/Main/include/ThreadTask.h
index edc09a3..35ab301 100644
--- a/src/VBox/Main/include/ThreadTask.h
+++ b/src/VBox/Main/include/ThreadTask.h
@@ -33,7 +33,10 @@ public:
 class ThreadTask
 {
 public:
-    ThreadTask(const Utf8Str &t) : m_hThread(NIL_RTTHREAD), m_strTaskName(t)
+    ThreadTask(const Utf8Str &t)
+        : m_hThread(NIL_RTTHREAD)
+        , m_strTaskName(t)
+        , mAsync(false)
     { }
 
     virtual ~ThreadTask()
@@ -43,8 +46,8 @@ public:
     HRESULT createThreadWithType(RTTHREADTYPE enmType);
     HRESULT createThreadWithRaceCondition(PRTTHREAD pThread);
 
-    virtual void handler() = 0;
     inline Utf8Str getTaskName() const { return m_strTaskName; }
+    bool isAsync() { return mAsync; }
 
 protected:
     HRESULT createThreadInternal(RTTHREADTYPE enmType, PRTTHREAD pThread);
@@ -56,6 +59,10 @@ protected:
     /** The worker thread handle (may be invalid if the thread has shut down). */
     RTTHREAD m_hThread;
     Utf8Str m_strTaskName;
+    bool mAsync;
+
+private:
+    virtual void handler() = 0;
 };
 
 #endif
diff --git a/src/VBox/Main/include/VirtualBoxClientImpl.h b/src/VBox/Main/include/VirtualBoxClientImpl.h
index 28423aa..ecdb0ed 100644
--- a/src/VBox/Main/include/VirtualBoxClientImpl.h
+++ b/src/VBox/Main/include/VirtualBoxClientImpl.h
@@ -66,6 +66,10 @@ private:
      * instances will return a failure at creation time and will not work. */
     static uint32_t g_cInstances;
 
+#ifdef RT_OS_WINDOWS
+    virtual HRESULT i_investigateVirtualBoxObjectCreationFailure(HRESULT hrc);
+#endif
+
     static DECLCALLBACK(int) SVCWatcherThread(RTTHREAD ThreadSelf, void *pvUser);
 
     struct Data
diff --git a/src/VBox/Main/src-all/ThreadTask.cpp b/src/VBox/Main/src-all/ThreadTask.cpp
index 29ee4db..282961d 100644
--- a/src/VBox/Main/src-all/ThreadTask.cpp
+++ b/src/VBox/Main/src-all/ThreadTask.cpp
@@ -96,6 +96,7 @@ HRESULT ThreadTask::createThreadInternal(RTTHREADTYPE enmType, PRTTHREAD phThrea
                              this->getTaskName().c_str());
     if (RT_SUCCESS(vrc))
     {
+        mAsync = true;
         if (phThread)
             *phThread = m_hThread;
         return S_OK;
diff --git a/src/VBox/Main/src-client/ConsoleImpl2.cpp b/src/VBox/Main/src-client/ConsoleImpl2.cpp
index 24d8979..b0483c0 100644
--- a/src/VBox/Main/src-client/ConsoleImpl2.cpp
+++ b/src/VBox/Main/src-client/ConsoleImpl2.cpp
@@ -4821,9 +4821,15 @@ int Console::i_configNetwork(const char *pszDevice,
                 /* port-forwarding */
                 SafeArray<BSTR> pfs;
                 hrc = natEngine->COMGETTER(Redirects)(ComSafeArrayAsOutParam(pfs));         H();
-                PCFGMNODE pPF = NULL;          /* /Devices/Dev/.../Config/PF#0/ */
+
+                PCFGMNODE pPFTree = NULL;
+                if (pfs.size() > 0)
+                    InsertConfigNode(pCfg, "PortForwarding", &pPFTree);
+
                 for (unsigned int i = 0; i < pfs.size(); ++i)
                 {
+                    PCFGMNODE pPF = NULL; /* /Devices/Dev/.../Config/PortForwarding/$n/ */
+
                     uint16_t port = 0;
                     BSTR r = pfs[i];
                     Utf8Str utf = Utf8Str(r);
@@ -4872,11 +4878,11 @@ int Console::i_configNetwork(const char *pszDevice,
                     if (!fValid)
                         continue;
 
-                    if (strName.isEmpty())
-                        VMSetError(VMR3GetVM(mpUVM), VERR_CFGM_NO_NODE, RT_SRC_POS,
-                                   N_("NAT redirection rule without a name"));
+                    InsertConfigNode(pPFTree, Utf8StrFmt("%u", i).c_str(), &pPF);
+
+                    if (!strName.isEmpty())
+                        InsertConfigString(pPF, "Name", strName);
 
-                    InsertConfigNode(pCfg, strName.c_str(), &pPF);
                     InsertConfigString(pPF, "Protocol", strProto);
 
                     if (!strHostIP.isEmpty())
diff --git a/src/VBox/Main/src-client/DisplayImpl.cpp b/src/VBox/Main/src-client/DisplayImpl.cpp
index 734dbda..956693f 100644
--- a/src/VBox/Main/src-client/DisplayImpl.cpp
+++ b/src/VBox/Main/src-client/DisplayImpl.cpp
@@ -4071,6 +4071,28 @@ DECLCALLBACK(int) Display::i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface,
         return VINF_SUCCESS;
     }
 
+    VBVAINFOSCREEN screenInfo;
+    RT_ZERO(screenInfo);
+
+    if (pScreen->u16Flags & VBVA_SCREEN_F_BLANK2)
+    {
+        /* Init a local VBVAINFOSCREEN structure, which will be used instead of
+         * the original pScreen. Set VBVA_SCREEN_F_BLANK, which will force
+         * the code below to choose the "blanking" branches.
+         */
+        screenInfo.u32ViewIndex    = pScreen->u32ViewIndex;
+        screenInfo.i32OriginX      = pFBInfo->xOrigin;
+        screenInfo.i32OriginY      = pFBInfo->yOrigin;
+        screenInfo.u32StartOffset  = 0; /* Irrelevant */
+        screenInfo.u32LineSize     = pFBInfo->u32LineSize;
+        screenInfo.u32Width        = pFBInfo->w;
+        screenInfo.u32Height       = pFBInfo->h;
+        screenInfo.u16BitsPerPixel = pFBInfo->u16BitsPerPixel;
+        screenInfo.u16Flags        = pScreen->u16Flags | VBVA_SCREEN_F_BLANK;
+
+        pScreen = &screenInfo;
+    }
+
     /* If display was disabled or there is no framebuffer, a resize will be required,
      * because the framebuffer was/will be changed.
      */
diff --git a/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp b/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
index b84687f..5822f41 100644
--- a/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
+++ b/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
@@ -27,6 +27,10 @@
 #include <iprt/critsect.h>
 #include <iprt/semaphore.h>
 #include <iprt/cpp/utils.h>
+#ifdef RT_OS_WINDOWS
+# include <iprt/ldr.h>
+# include <msi.h>
+#endif
 
 
 /** Waiting time between probing whether VBoxSVC is alive. */
@@ -90,7 +94,11 @@ HRESULT VirtualBoxClient::init()
 
         rc = mData.m_pVirtualBox.createLocalObject(CLSID_VirtualBox);
         if (FAILED(rc))
+#ifdef RT_OS_WINDOWS
+            throw i_investigateVirtualBoxObjectCreationFailure(rc);
+#else
             throw rc;
+#endif
 
         /* VirtualBox error return is postponed to method calls, fetch it. */
         ULONG rev;
@@ -156,6 +164,174 @@ HRESULT VirtualBoxClient::init()
     return S_OK;
 }
 
+#ifdef RT_OS_WINDOWS
+/**
+ * Looks into why we failed to create the VirtualBox object.
+ *
+ * @returns hrcCaller thru setError.
+ * @param   hrcCaller   The failure status code.
+ */
+HRESULT VirtualBoxClient::i_investigateVirtualBoxObjectCreationFailure(HRESULT hrcCaller)
+{
+    /*
+     * First step is to try get an IUnknown interface of the VirtualBox object.
+     *
+     * This will succeed even when oleaut32.msm (see @bugref{8016}, @ticketref{12087})
+     * is accidentally installed and messes up COM.  It may also succeed when the COM
+     * registration is partially broken (though that's unlikely to happen these days).
+     */
+    IUnknown *pUnknown = NULL;
+    HRESULT hrc = CoCreateInstance(CLSID_VirtualBox, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void **)&pUnknown);
+    if (FAILED(hrc))
+    {
+        if (hrc == hrcCaller)
+            return setError(hrcCaller, tr("Completely failed to instantiate CLSID_VirtualBox: %Rhrc"), hrcCaller);
+        return setError(hrcCaller, tr("Completely failed to instantiate CLSID_VirtualBox: %Rhrc & %Rhrc"), hrcCaller, hrc);
+    }
+
+    /*
+     * Try query the IVirtualBox interface (should fail), if it succeed we return
+     * straight away so we have more columns to spend on long messages below.
+     */
+    IVirtualBox *pVirtualBox;
+    hrc = pUnknown->QueryInterface(IID_IVirtualBox, (void **)&pVirtualBox);
+    if (SUCCEEDED(hrc))
+    {
+        pVirtualBox->Release();
+        pUnknown->Release();
+        return setError(hrcCaller,
+                        tr("Failed to instantiate CLSID_VirtualBox the first time, but worked when checking out why ... weird"));
+    }
+
+    /*
+     * Check for oleaut32.msm traces in the registry.
+     */
+    HKEY hKey;
+    LSTATUS lrc = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID\\{00020420-0000-0000-C000-000000000046}\\InprocServer32",
+                                0 /*fFlags*/, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | STANDARD_RIGHTS_READ, &hKey);
+    if (lrc == ERROR_SUCCESS)
+    {
+        wchar_t wszBuf[8192];
+        DWORD   cbBuf  = sizeof(wszBuf) - sizeof(wchar_t);
+        DWORD   dwType = 0;
+        lrc = RegQueryValueExW(hKey, L"InprocServer32", NULL /*pvReserved*/, &dwType, (BYTE *)&wszBuf[0], &cbBuf);
+        if (lrc == ERROR_SUCCESS)
+        {
+            wszBuf[cbBuf / sizeof(wchar_t)] = '\0';
+            bool fSetError = false;
+
+            /*
+             * Try decode the string and improve the message.
+             */
+            typedef UINT (WINAPI *PFNMSIDECOMPOSEDESCRIPTORW)(PCWSTR pwszDescriptor,
+                                                              LPWSTR pwszProductCode /*[40]*/,
+                                                              LPWSTR pwszFeatureId /*[40]*/,
+                                                              LPWSTR pwszComponentCode /*[40]*/,
+                                                              DWORD *poffArguments);
+            PFNMSIDECOMPOSEDESCRIPTORW pfnMsiDecomposeDescriptorW;
+            pfnMsiDecomposeDescriptorW = (PFNMSIDECOMPOSEDESCRIPTORW)RTLdrGetSystemSymbol("msi.dll", "MsiDecomposeDescriptorW");
+            if (   pfnMsiDecomposeDescriptorW
+                && (   dwType == REG_SZ
+                    || dwType == REG_MULTI_SZ))
+            {
+                wchar_t wszProductCode[RTUUID_STR_LENGTH + 2 + 16]   = { 0 };
+                wchar_t wszFeatureId[RTUUID_STR_LENGTH + 2 + 16]     = { 0 };
+                wchar_t wszComponentCode[RTUUID_STR_LENGTH + 2 + 16] = { 0 };
+                DWORD   offArguments = ~(DWORD)0;
+                UINT uRc = pfnMsiDecomposeDescriptorW(wszBuf, wszProductCode, wszFeatureId, wszComponentCode, &offArguments);
+                if (uRc == 0)
+                {
+                    /*
+                     * Can we resolve the product code into a name?
+                     */
+                    typedef UINT (WINAPI *PFNMSIOPENPRODUCTW)(PCWSTR, MSIHANDLE *);
+                    PFNMSIOPENPRODUCTW pfnMsiOpenProductW;
+                    pfnMsiOpenProductW = (PFNMSIOPENPRODUCTW)RTLdrGetSystemSymbol("msi.dll", "MsiOpenProductW");
+
+                    typedef UINT (WINAPI *PFNMSICLOSEHANDLE)(MSIHANDLE);
+                    PFNMSICLOSEHANDLE pfnMsiCloseHandle;
+                    pfnMsiCloseHandle = (PFNMSICLOSEHANDLE)RTLdrGetSystemSymbol("msi.dll", "MsiCloseHandle");
+
+                    typedef UINT (WINAPI *PFNGETPRODUCTPROPERTYW)(MSIHANDLE, PCWSTR, PWSTR, PDWORD);
+                    PFNGETPRODUCTPROPERTYW pfnMsiGetProductPropertyW;
+                    pfnMsiGetProductPropertyW = (PFNGETPRODUCTPROPERTYW)RTLdrGetSystemSymbol("msi.dll", "MsiGetProductPropertyW");
+                    if (   pfnMsiGetProductPropertyW
+                        && pfnMsiCloseHandle
+                        && pfnMsiOpenProductW)
+                    {
+                        MSIHANDLE hMsi = 0;
+                        uRc = pfnMsiOpenProductW(wszProductCode, &hMsi);
+                        if (uRc == 0)
+                        {
+                            static wchar_t const * const s_apwszProps[] =
+                            {
+                                INSTALLPROPERTY_INSTALLEDPRODUCTNAME,
+                                INSTALLPROPERTY_PRODUCTNAME,
+                                INSTALLPROPERTY_PACKAGENAME,
+                            };
+
+                            wchar_t  wszProductName[1024];
+                            DWORD    cwcProductName;
+                            unsigned i = 0;
+                            do
+                            {
+                                cwcProductName = RT_ELEMENTS(wszProductName) - 1;
+                                uRc = pfnMsiGetProductPropertyW(hMsi, s_apwszProps[i], wszProductName, &cwcProductName);
+                            }
+                            while (   ++i < RT_ELEMENTS(s_apwszProps)
+                                   && (   uRc != 0
+                                       || cwcProductName < 2
+                                       || cwcProductName >= RT_ELEMENTS(wszProductName)) );
+                            uRc = pfnMsiCloseHandle(hMsi);
+                            if (uRc == 0 && cwcProductName >= 2)
+                            {
+                                wszProductName[RT_MIN(cwcProductName, RT_ELEMENTS(wszProductName) - 1)] = '\0';
+                                setError(hrcCaller,
+                                         tr("Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknown works.\n"
+                                            "PSDispatch looks broken by the '%ls' (%ls) program, suspecting that it features the broken oleaut32.msm module as component %ls.\n"
+                                            "\n"
+                                            "We suggest you try uninstall '%ls'.\n"
+                                            "\n"
+                                            "See also https://support.microsoft.com/en-us/kb/316911 "),
+                                         wszProductName, wszProductCode, wszComponentCode, wszProductName);
+                                fSetError = true;
+                            }
+                        }
+                    }
+
+                    /* MSI uses COM and may mess up our stuff. So, we wait with the fallback till afterwards in this case. */
+                    if (!fSetError)
+                    {
+                        setError(hrcCaller,
+                                 tr("Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, CLSID_VirtualBox w/ IUnknown works.\n"
+                                    "PSDispatch looks broken by installer %ls featuring the broken oleaut32.msm module as component %ls.\n"
+                                    "\n"
+                                    "See also https://support.microsoft.com/en-us/kb/316911 "),
+                                 wszProductCode, wszComponentCode);
+                        fSetError = true;
+                    }
+                }
+            }
+            if (!fSetError)
+                setError(hrcCaller, tr("Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, CLSID_VirtualBox w/ IUnknown works.\n"
+                                       "PSDispatch looks broken by some installer featuring the broken oleaut32.msm module as a component.\n"
+                                       "\n"
+                                       "See also https://support.microsoft.com/en-us/kb/316911 "));
+        }
+        else if (lrc == ERROR_FILE_NOT_FOUND)
+            setError(hrcCaller, tr("Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknown works.\n"
+                                   "PSDispatch looks fine. Weird"));
+        else
+            setError(hrcCaller, tr("Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknown works.\n"
+                                   "Checking out PSDispatch registration ended with error: %u (%#x)"), lrc, lrc);
+        RegCloseKey(hKey);
+    }
+
+    pUnknown->Release();
+    return hrcCaller;
+}
+#endif /* RT_OS_WINDOWS */
+
 /**
  *  Uninitializes the instance and sets the ready flag to FALSE.
  *  Called either from FinalRelease() or by the parent when it gets destroyed.
diff --git a/src/VBox/Main/src-server/MediumImpl.cpp b/src/VBox/Main/src-server/MediumImpl.cpp
index ec8e206..64464ef 100644
--- a/src/VBox/Main/src-server/MediumImpl.cpp
+++ b/src/VBox/Main/src-server/MediumImpl.cpp
@@ -43,7 +43,6 @@
 #include <algorithm>
 #include <list>
 
-#include <openssl/rand.h>
 
 typedef std::list<Guid> GuidList;
 
@@ -224,7 +223,6 @@ public:
           mVDOperationIfaces(NULL),
           mMedium(aMedium),
           mMediumCaller(aMedium),
-          mThread(NIL_RTTHREAD),
           mProgress(aProgress),
           mVirtualBoxCaller(NULL)
     {
@@ -259,15 +257,14 @@ public:
     virtual ~Task()
     {
         /* send the notification of completion.*/
-        if (!mProgress.isNull())
+        if (   isAsync()
+            && !mProgress.isNull())
             mProgress->i_notifyComplete(mRC);
     }
 
     HRESULT rc() const { return mRC; }
     bool isOk() const { return SUCCEEDED(rc()); }
 
-    bool isAsync() { return mThread != NIL_RTTHREAD; }
-
     const ComPtr<Progress>& GetProgressObject() const {return mProgress;}
 
     /**
@@ -312,7 +309,6 @@ public:
 
 protected:
     HRESULT mRC;
-    RTTHREAD mThread;
 
 private:
     virtual HRESULT executeTask() = 0;
@@ -7899,7 +7895,7 @@ HRESULT Medium::i_taskCreateBaseHandler(Medium::CreateBaseTask &task)
         AutoWriteLock treeLock(m->pVirtualBox->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
         ComObjPtr<Medium> pMedium;
         rc = m->pVirtualBox->i_registerMedium(this, &pMedium, treeLock);
-        Assert(this == pMedium);
+        Assert(pMedium == NULL || this == pMedium);
     }
 
     // re-acquire the lock before changing state
diff --git a/src/VBox/Main/src-server/MediumLock.cpp b/src/VBox/Main/src-server/MediumLock.cpp
index bdf553b..2376ade 100644
--- a/src/VBox/Main/src-server/MediumLock.cpp
+++ b/src/VBox/Main/src-server/MediumLock.cpp
@@ -29,6 +29,9 @@ MediumLock::MediumLock()
 
 MediumLock::~MediumLock()
 {
+    // destroying medium locks is routinely done as part of error handling
+    // and it's not expected to lose error info
+    ErrorInfoKeeper eik;
     Unlock();
 }
 
@@ -155,6 +158,9 @@ MediumLockList::MediumLockList()
 
 MediumLockList::~MediumLockList()
 {
+    // destroying medium lock lists is routinely done as part of error handling
+    // and it's not expected to lose error info
+    ErrorInfoKeeper eik;
     Clear();
     // rest is done by the list object's destructor
 }
@@ -268,6 +274,9 @@ MediumLockListMap::MediumLockListMap()
 
 MediumLockListMap::~MediumLockListMap()
 {
+    // destroying medium lock list maps is routinely done as part of
+    // error handling and it's not expected to lose error info
+    ErrorInfoKeeper eik;
     Clear();
     // rest is done by the map object's destructor
 }
diff --git a/src/VBox/Main/src-server/NATEngineImpl.cpp b/src/VBox/Main/src-server/NATEngineImpl.cpp
index b85f43c..94920c2 100644
--- a/src/VBox/Main/src-server/NATEngineImpl.cpp
+++ b/src/VBox/Main/src-server/NATEngineImpl.cpp
@@ -259,8 +259,21 @@ HRESULT NATEngine::addRedirect(const com::Utf8Str &aName, NATProtocol_T aProto,
         default:
             return E_INVALIDARG;
     }
+
     if (name.isEmpty())
         name = Utf8StrFmt("%s_%d_%d", proto, aHostPort, aGuestPort);
+    else
+    {
+        const char *s;
+        char c;
+
+        for (s = name.c_str(); (c = *s) != '\0'; ++s)
+        {
+            if (c == ',') /* we use csv in several places e.g. GetRedirects or natpf<N> argument */
+                return setError(E_INVALIDARG,
+                                tr("'%c' - invalid character in NAT rule name"), c);
+        }
+    }
 
     settings::NATRulesMap::iterator it;
     for (it = mData->m->mapRules.begin(); it != mData->m->mapRules.end(); ++it)
diff --git a/src/VBox/Main/src-server/SnapshotImpl.cpp b/src/VBox/Main/src-server/SnapshotImpl.cpp
index 364644b..45e4e89 100644
--- a/src/VBox/Main/src-server/SnapshotImpl.cpp
+++ b/src/VBox/Main/src-server/SnapshotImpl.cpp
@@ -3093,7 +3093,13 @@ void SessionMachine::i_deleteSnapshotHandler(DeleteSnapshotTask &task)
             }
 
             if (fNeedSourceUninit)
+            {
+                // make sure that the diff image to be deleted has no parent,
+                // even in error cases (where the deparenting may be missing)
+                if (it->mpSource->i_getParent())
+                    it->mpSource->i_deparent();
                 it->mpSource->uninit();
+            }
 
             // One attachment is merged, must save the settings
             mParent->i_markRegistryModified(i_getId());
diff --git a/src/VBox/Main/src-server/StorageControllerImpl.cpp b/src/VBox/Main/src-server/StorageControllerImpl.cpp
index 98a1313..547cdd4 100644
--- a/src/VBox/Main/src-server/StorageControllerImpl.cpp
+++ b/src/VBox/Main/src-server/StorageControllerImpl.cpp
@@ -152,6 +152,7 @@ HRESULT StorageController::init(Machine *aParent,
         case StorageBus_SAS:
             m->bd->ulPortCount = 8;
             m->bd->controllerType = StorageControllerType_LsiLogicSas;
+            break;
         case StorageBus_USB:
             m->bd->ulPortCount = 8;
             m->bd->controllerType = StorageControllerType_USB;
diff --git a/src/VBox/Main/webservice/Makefile.kmk b/src/VBox/Main/webservice/Makefile.kmk
index 4d255e4..656b665 100644
--- a/src/VBox/Main/webservice/Makefile.kmk
+++ b/src/VBox/Main/webservice/Makefile.kmk
@@ -201,6 +201,7 @@ VBOXWEB_OTHERS += \
 # disable -fvisibility=hidden as the SOAP stuff does not properly set the visibility attributes
 TEMPLATE_VBOXWEBR3EXE = Webservices without -fvisibility
 TEMPLATE_VBOXWEBR3EXE_EXTENDS = VBOXR3EXE
+TEMPLATE_VBOXWEBR3EXE_DEFS.win += WIN32_LEAN_AND_MEAN $(TEMPLATE_VBOXR3EXE_DEFS.win) # Makes the redefinition warnings go away.
 TEMPLATE_VBOXWEBR3EXE_CXXFLAGS = $(filter-out $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden),\
 				 $(TEMPLATE_VBOXR3EXE_CXXFLAGS))
 
@@ -213,6 +214,7 @@ ifdef VBOX_GSOAP_INSTALLED
   vboxsoap_TEMPLATE = VBOXWEBR3EXE
   vboxsoap_CXXFLAGS += $(VBOX_C_CXX_FLAGS_NO_UNUSED_PARAMETERS)
   vboxsoap_CXXFLAGS.win += -bigobj
+  vboxsoap_CXXFLAGS.win += -wd4702 # soapc-4.cpp(16) : warning C4702: unreachable code
   ifn1of ($(KBUILD_TARGET), win)
    vboxsoap_CXXFLAGS += -Wno-shadow -Wno-parentheses $(VBOX_GCC_Wno-literal-suffix)
   endif
@@ -254,7 +256,9 @@ ifdef VBOX_GSOAP_INSTALLED
 	$(VBOXWEB_OUT_DIR)/soapC-19.cpp \
 	$(VBOXWEB_OUT_DIR)/soapC-20.cpp
   vboxsoap_CXXFLAGS += \
-  	$(VBOX_GCC_Wno-vla)
+  	$(VBOX_GCC_Wno-vla) \
+	$(if-expr $(KBUILD_TARGET) == "win",,-Wno-format) \
+  	$(if-expr $(KBUILD_TARGET) == "win",,-Wno-deprecated-declarations)
   endif
   vboxsoap_CLEAN := $(vboxsoap_SOURCES) # lazy bird
   vboxsoap_SOURCES += \
@@ -310,6 +314,7 @@ ifdef VBOX_GSOAP_INSTALLED
  PROGRAMS += vboxwebsrv
  vboxwebsrv_TEMPLATE = VBOXMAINCLIENTEXE
  vboxwebsrv_DEFS += SOCKET_CLOSE_ON_EXEC
+ vboxwebsrv_DEFS.win += WIN32_LEAN_AND_MEAN
  vboxwebsrv_INCS = \
 	$(VBOX_GSOAP_INCS) \
 	$(VBOXWEB_OUT_DIR) \
@@ -338,7 +343,9 @@ ifdef VBOX_GSOAP_INSTALLED
 	$(VBOXWEB_OUT_DIR)/methodmaps.cpp \
 	$(VBOXWEB_OUT_DIR)/soapServer.cpp \
     $(VBOXWEB_OUT_DIR)/vboxweb-wsdl.c
-
+ # gcc 6.2 warns about aborting misleading indentation detection (too much code)
+ vboxweb.cpp_CXXFLAGS = \
+	$(VBOX_GCC_Wno-misleading-indentation)
  vboxweb.cpp_DEFS = \
 	$(if $(VBOX_BLEEDING_EDGE),VBOX_BLEEDING_EDGE=\"$(VBOX_BLEEDING_EDGE)\",)
 
diff --git a/src/VBox/Main/webservice/vboxweb.cpp b/src/VBox/Main/webservice/vboxweb.cpp
index d0ad8c5..da630a9 100644
--- a/src/VBox/Main/webservice/vboxweb.cpp
+++ b/src/VBox/Main/webservice/vboxweb.cpp
@@ -50,6 +50,10 @@
 #include <iprt/stream.h>
 #include <iprt/asm.h>
 
+#ifdef WITH_OPENSSL
+# include <openssl/opensslv.h>
+#endif
+
 #ifndef RT_OS_WINDOWS
 # include <signal.h>
 #endif
@@ -748,10 +752,11 @@ static const char * decodeAuthResult(AuthResult result)
     }
 }
 
-#ifdef WITH_OPENSSL
+#if defined(WITH_OPENSSL) && (OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER))
 /****************************************************************************
  *
- * OpenSSL convenience functions for multithread support
+ * OpenSSL convenience functions for multithread support.
+ * Not required for OpenSSL 1.1+
  *
  ****************************************************************************/
 
@@ -853,7 +858,7 @@ static void CRYPTO_thread_cleanup()
     RTMemFree(g_pSSLMutexes);
     g_pSSLMutexes = NULL;
 }
-#endif /* WITH_OPENSSL */
+#endif /* WITH_OPENSSL && (OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)) */
 
 /****************************************************************************
  *
@@ -863,13 +868,13 @@ static void CRYPTO_thread_cleanup()
 
 static void doQueuesLoop()
 {
-#ifdef WITH_OPENSSL
+#if defined(WITH_OPENSSL) && (OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER))
     if (g_fSSL && CRYPTO_thread_setup())
     {
         LogRel(("Failed to set up OpenSSL thread mutex!"));
         exit(RTEXITCODE_FAILURE);
     }
-#endif /* WITH_OPENSSL */
+#endif 
 
     // set up gSOAP
     struct soap soap;
@@ -964,10 +969,10 @@ static void doQueuesLoop()
     }
     soap_done(&soap); // close master socket and detach environment
 
-#ifdef WITH_OPENSSL
+#if defined(WITH_OPENSSL) && (OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER))
     if (g_fSSL)
         CRYPTO_thread_cleanup();
-#endif /* WITH_OPENSSL */
+#endif
 }
 
 /**
diff --git a/src/VBox/Main/webservice/vboxweb.h b/src/VBox/Main/webservice/vboxweb.h
index f47e583..6038d67 100644
--- a/src/VBox/Main/webservice/vboxweb.h
+++ b/src/VBox/Main/webservice/vboxweb.h
@@ -1,6 +1,9 @@
+/* $Id:  $ */
+/** @file
+ * vboxweb.h - header file for "real" web server code.
+ */
+
 /*
- * vboxweb.h:
- *      header file for "real" web server code.
  *
  * Copyright (C) 2006-2016 Oracle Corporation
  *
diff --git a/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp b/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
index 0d836db..4c5a1db 100644
--- a/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
+++ b/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
@@ -114,6 +114,11 @@ private:
     int initNoMain();
     int initWithMain();
     HRESULT HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent);
+
+    static int hostDnsServers(const ComHostPtr& host,
+                              const RTNETADDRIPV4& networkid,
+                              const AddressToOffsetMapping& mapping,
+                              AddressList& servers);
     int fetchAndUpdateDnsInfo();
 
 protected:
@@ -610,6 +615,65 @@ int VBoxNetDhcp::fetchAndUpdateDnsInfo()
     return VINF_SUCCESS;
 }
 
+
+int VBoxNetDhcp::hostDnsServers(const ComHostPtr& host,
+                                const RTNETADDRIPV4& networkid,
+                                const AddressToOffsetMapping& mapping,
+                                AddressList& servers)
+{
+    ComBstrArray strs;
+
+    HRESULT hrc = host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs));
+    if (FAILED(hrc))
+        return VERR_NOT_FOUND;
+
+    /*
+     * Recent fashion is to run dnsmasq on 127.0.1.1 which we
+     * currently can't map.  If that's the only nameserver we've got,
+     * we need to use DNS proxy for VMs to reach it.
+     */
+    bool fUnmappedLoopback = false;
+
+    for (size_t i = 0; i < strs.size(); ++i)
+    {
+        RTNETADDRIPV4 addr;
+        int rc;
+
+        rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr);
+        if (RT_FAILURE(rc))
+            continue;
+
+        if (addr.au8[0] == 127)
+        {
+            AddressToOffsetMapping::const_iterator remap(mapping.find(addr));
+
+            if (remap != mapping.end())
+            {
+                int offset = remap->second;
+                addr.u = RT_H2N_U32(RT_N2H_U32(networkid.u) + offset);
+            }
+            else
+            {
+                fUnmappedLoopback = true;
+                continue;
+            }
+        }
+
+        servers.push_back(addr);
+    }
+
+    if (servers.empty() && fUnmappedLoopback)
+    {
+        RTNETADDRIPV4 proxy;
+
+        proxy.u = networkid.u | RT_H2N_U32_C(1U);
+        servers.push_back(proxy);
+    }
+
+    return VINF_SUCCESS;
+}
+
+
 HRESULT VBoxNetDhcp::HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent)
 {
     switch (aEventType)
diff --git a/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp b/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp
index 706937e..c9a8e06 100644
--- a/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp
+++ b/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp
@@ -118,48 +118,6 @@ int localMappings(const ComNatPtr& nat, AddressToOffsetMapping& mapping)
     return VINF_SUCCESS;
 }
 
-/**
- * @note: const dropped here, because of map<K,V>::operator[] which isn't const, map<K,V>::at() has const
- * variant but it's C++11.
- */
-int hostDnsServers(const ComHostPtr& host, const RTNETADDRIPV4& networkid,
-                   /*const*/ AddressToOffsetMapping& mapping, AddressList& servers)
-{
-    servers.clear();
-
-    ComBstrArray strs;
-    if (SUCCEEDED(host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs))))
-    {
-        RTNETADDRIPV4 addr;
-        int rc;
-
-        for (unsigned int i = 0; i < strs.size(); ++i)
-        {
-            rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr);
-            if (RT_SUCCESS(rc))
-            {
-                if (addr.au8[0] == 127)
-                {
-                    /* XXX: here we want map<K,V>::at(const K& k) const */
-                    if (mapping[addr] != 0)
-                    {
-                        addr.u = RT_H2N_U32(RT_N2H_U32(networkid.u)
-                                            + mapping[addr]);
-                    }
-                    else
-                        continue; /* XXX: Warning here (local mapping wasn't registered) */
-                }
-
-                servers.push_back(addr);
-            }
-        }
-    }
-    else
-        return VERR_NOT_FOUND;
-
-    return VINF_SUCCESS;
-}
-
 
 int hostDnsSearchList(const ComHostPtr& host, std::vector<std::string>& strings)
 {
diff --git a/src/VBox/NetworkServices/NetLib/utils.h b/src/VBox/NetworkServices/NetLib/utils.h
index 011e7f1..25f5c89 100644
--- a/src/VBox/NetworkServices/NetLib/utils.h
+++ b/src/VBox/NetworkServices/NetLib/utils.h
@@ -74,7 +74,6 @@ inline RTNETADDRIPV4 networkid(const RTNETADDRIPV4& addr, const RTNETADDRIPV4& n
 
 
 int localMappings(const ComNatPtr&, AddressToOffsetMapping&);
-int hostDnsServers(const ComHostPtr&, const RTNETADDRIPV4&,/* const */ AddressToOffsetMapping&, AddressList&);
 int hostDnsSearchList(const ComHostPtr&, std::vector<std::string>&);
 int hostDnsDomain(const ComHostPtr&, std::string& domainStr);
 
diff --git a/src/VBox/RDP/client-1.8.3/ssl.c b/src/VBox/RDP/client-1.8.3/ssl.c
index dac5511..254e886 100644
--- a/src/VBox/RDP/client-1.8.3/ssl.c
+++ b/src/VBox/RDP/client-1.8.3/ssl.c
@@ -96,6 +96,38 @@ void
 rdssl_rsa_encrypt(uint8 * out, uint8 * in, int len, uint32 modulus_size, uint8 * modulus,
 		  uint8 * exponent)
 {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+	BN_CTX *ctx;
+	BIGNUM *mod, *exp, *x, *y;
+	uint8 inr[SEC_MAX_MODULUS_SIZE];
+	int outlen;
+
+	reverse(modulus, modulus_size);
+	reverse(exponent, SEC_EXPONENT_SIZE);
+	memcpy(inr, in, len);
+	reverse(inr, len);
+
+	ctx = BN_CTX_new();
+	mod = BN_new();
+	exp = BN_new();
+	x = BN_new();
+	y = BN_new();
+
+	BN_bin2bn(modulus, modulus_size, mod);
+	BN_bin2bn(exponent, SEC_EXPONENT_SIZE, exp);
+	BN_bin2bn(inr, len, x);
+	BN_mod_exp(y, x, exp, mod, ctx);
+	outlen = BN_bn2bin(y, out);
+	reverse(out, outlen);
+	if (outlen < (int) modulus_size)
+		memset(out + outlen, 0, modulus_size - outlen);
+
+	BN_free(y);
+	BN_clear_free(x);
+	BN_free(exp);
+	BN_free(mod);
+	BN_CTX_free(ctx);
+#else /* OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER) */
 	BN_CTX *ctx;
 	BIGNUM mod, exp, x, y;
 	uint8 inr[SEC_MAX_MODULUS_SIZE];
@@ -126,6 +158,7 @@ rdssl_rsa_encrypt(uint8 * out, uint8 * in, int len, uint32 modulus_size, uint8 *
 	BN_free(&exp);
 	BN_free(&mod);
 	BN_CTX_free(ctx);
+#endif /* OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER) */
 }
 
 /* returns newly allocated RDSSL_CERT or NULL */
@@ -155,6 +188,19 @@ rdssl_cert_to_rkey(RDSSL_CERT * cert, uint32 * key_len)
 
 	   Kudos to Richard Levitte for the following (. intiutive .) 
 	   lines of code that resets the OID and let's us extract the key. */
+#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+	X509_PUBKEY *x509_pk = X509_get_X509_PUBKEY(cert);
+	X509_ALGOR *algor;
+	const ASN1_OBJECT *alg_obj;
+	X509_PUBKEY_get0_param(NULL, NULL, NULL, &algor, x509_pk);
+	X509_ALGOR_get0(&alg_obj, NULL, NULL, algor);
+	nid = OBJ_obj2nid(alg_obj);
+	if ((nid == NID_md5WithRSAEncryption) || (nid == NID_shaWithRSAEncryption))
+	{
+		DEBUG_RDP5(("Re-setting algorithm type to RSA in server certificate\n"));
+                X509_ALGOR_set0(algor, OBJ_nid2obj(NID_rsaEncryption), 0, NULL);
+	}
+#else /* OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER) */
 	nid = OBJ_obj2nid(cert->cert_info->key->algor->algorithm);
 	if ((nid == NID_md5WithRSAEncryption) || (nid == NID_shaWithRSAEncryption))
 	{
@@ -162,6 +208,7 @@ rdssl_cert_to_rkey(RDSSL_CERT * cert, uint32 * key_len)
 		ASN1_OBJECT_free(cert->cert_info->key->algor->algorithm);
 		cert->cert_info->key->algor->algorithm = OBJ_nid2obj(NID_rsaEncryption);
 	}
+#endif /* OPENSSL_VERSION_NUMBER < 0x10100000 || && defined(LIBRESSL_VERSION_NUMBER) */
 	epk = X509_get_pubkey(cert);
 	if (NULL == epk)
 	{
@@ -210,6 +257,19 @@ rdssl_rkey_get_exp_mod(RDSSL_RKEY * rkey, uint8 * exponent, uint32 max_exp_len,
 {
 	int len;
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+	const BIGNUM *e, *n;
+	RSA_get0_key(rkey, &n, &e, NULL);
+	if ((BN_num_bytes(e) > (int) max_exp_len) ||
+	    (BN_num_bytes(n) > (int) max_mod_len))
+	{
+		return 1;
+	}
+	len = BN_bn2bin(e, exponent);
+	reverse(exponent, len);
+	len = BN_bn2bin(n, modulus);
+	reverse(modulus, len);
+#else
 	if ((BN_num_bytes(rkey->e) > (int) max_exp_len) ||
 	    (BN_num_bytes(rkey->n) > (int) max_mod_len))
 	{
@@ -219,6 +279,7 @@ rdssl_rkey_get_exp_mod(RDSSL_RKEY * rkey, uint8 * exponent, uint32 max_exp_len,
 	reverse(exponent, len);
 	len = BN_bn2bin(rkey->n, modulus);
 	reverse(modulus, len);
+#endif
 	return 0;
 }
 
@@ -238,8 +299,12 @@ void
 rdssl_hmac_md5(const void *key, int key_len, const unsigned char *msg, int msg_len,
 	       unsigned char *md)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
 	HMAC_CTX ctx;
 	HMAC_CTX_init(&ctx);
+#endif
 	HMAC(EVP_md5(), key, key_len, msg, msg_len, md, NULL);
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
 	HMAC_CTX_cleanup(&ctx);
+#endif
 }
diff --git a/src/VBox/RDP/client-1.8.3/tcp.c b/src/VBox/RDP/client-1.8.3/tcp.c
index a88b56e..326b6c4 100644
--- a/src/VBox/RDP/client-1.8.3/tcp.c
+++ b/src/VBox/RDP/client-1.8.3/tcp.c
@@ -319,7 +319,18 @@ tcp_tls_connect(void)
 	/* create process context */
 	if (g_ssl_ctx == NULL)
 	{
+#ifdef __GNUC__
+# if (__GNUC__ << 8) + __GNUC_MINOR__ >= 0x406
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+# endif
+#endif
 		g_ssl_ctx = SSL_CTX_new(TLSv1_client_method());
+#ifdef __GNUC__
+# if (__GNUC__ << 8) + __GNUC_MINOR__ >= 0x406
+#  pragma GCC diagnostic pop
+# endif
+#endif
 		if (g_ssl_ctx == NULL)
 		{
 			error("tcp_tls_connect: SSL_CTX_new() failed to create TLS v1.0 context\n");
diff --git a/src/VBox/Runtime/Makefile.kmk b/src/VBox/Runtime/Makefile.kmk
index 89015e4..0bc429e 100644
--- a/src/VBox/Runtime/Makefile.kmk
+++ b/src/VBox/Runtime/Makefile.kmk
@@ -779,7 +779,7 @@ RuntimeR3_SOURCES.win = \
 	generic/RTSemMutexRequest-generic.cpp \
 	generic/RTSemMutexRequestDebug-generic.cpp \
 	generic/RTThreadSetAffinityToCpu-generic.cpp \
-	generic/mppresent-generic.cpp \
+	generic/mppresent-generic-online.cpp \
 	generic/semrw-$(if-expr defined(VBOX_WITH_LOCKLESS_SEMRW),lockless-,)generic.cpp \
 	generic/uuid-generic.cpp \
 	generic/RTProcDaemonize-generic.cpp \
@@ -1497,6 +1497,9 @@ VBoxRT_SOURCES                := \
 		$(patsubst common/checksum/alt-%,common/checksum/openssl-%,$(RuntimeR3_SOURCES)) ) ) \
 	common/checksum/crc32-zlib.cpp \
 	common/misc/aiomgr.cpp
+ifneq ($(KBUILD_TARGET),win)
+VBox/VBoxRTDeps.cpp_CXXFLAGS = -Wno-deprecated-declarations
+endif
 ifdef VBOX_WITH_LIBCURL
  VBoxRT_SOURCES               += \
  	common/misc/s3.cpp \
@@ -1592,9 +1595,12 @@ VBoxRT_LDFLAGS.win             = /MANIFEST \
 	/delayload:advapi32.dll
 
 if1of ($(DLLS), VBoxRT)
+VBoxRT_CLEAN += $(VBoxRT_0_OUTDIR)/VBoxRT.def
 $$(VBoxRT_0_OUTDIR)/VBoxRT.def: \
 		$(PATH_SUB_CURRENT)/r3/win/VBoxRT-$$(if-expr $$(KBUILD_TARGET_ARCH) == amd64,win64,win32).def \
-		$(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def) \
+		$(if-expr defined(VBOX_WITH_OPENSSL_PRE_1_1)\
+		,$(PATH_SUB_CURRENT)/r3/win/VBoxRT-openssl-pre-1.1.def \
+		,$(PATH_SUB_CURRENT)/r3/win/VBoxRT-openssl-1.1plus.def )\
 		$(if-expr "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86" && defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES)\
 		,$(PATH_SUB_CURRENT)/r3/win/VBoxRT-msvcr100-win32.def ,) #$(PATH_SUB_CURRENT)/r3/win/VBoxRT-msvcp100-win32.def
 	$(RM) -f -- $@
@@ -1724,10 +1730,10 @@ VBoxRT-x86_LIBS.win                = \
 
 VBoxRT-x86_SOURCES.win = $(filter-out %.def %.rc,$(VBoxRT_SOURCES.win)) \
 	$(VBoxRT-x86_0_OUTDIR)/VBoxRT-x86.def
+VBoxRT-x86_CLEAN += $(VBoxRT-x86_0_OUTDIR)/VBoxRT-x86.def
 if1of ($(DLLS), VBoxRT-x86)
 $$(VBoxRT-x86_0_OUTDIR)/VBoxRT-x86.def: \
-		$(PATH_SUB_CURRENT)/r3/win/VBoxRT-win32.def \
-		$(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def)
+		$(PATH_SUB_CURRENT)/r3/win/VBoxRT-win32.def # Hopefully no need to export openssl here.
 	$(RM) -f -- $@
 	$(REDIRECT) -wto $@ -- $(CAT_EXT) $^
 endif
@@ -2240,7 +2246,7 @@ RuntimeR0Drv_SOURCES.win = \
 	generic/RTAssertShouldPanic-generic.cpp \
 	generic/RTLogWriteStdOut-stub-generic.cpp \
 	generic/RTTimerCreate-generic.cpp \
-	generic/mppresent-generic.cpp \
+	generic/mppresent-generic-online.cpp \
 	generic/RTMpGetCoreCount-generic.cpp \
 	nt/RTErrConvertFromNtStatus.cpp \
 	nt/RTNtPathExpand8dot3Path.cpp \
@@ -2256,7 +2262,6 @@ RuntimeR0Drv_SOURCES.win = \
 	r0drv/nt/memobj-r0drv-nt.cpp \
 	r0drv/nt/memuserkernel-r0drv-nt.cpp \
 	r0drv/nt/mp-r0drv-nt.cpp \
-	r0drv/nt/mpnotification-r0drv-nt.cpp \
 	r0drv/nt/process-r0drv-nt.cpp \
 	r0drv/nt/RTLogWriteDebugger-r0drv-nt.cpp \
 	r0drv/nt/semevent-r0drv-nt.cpp \
diff --git a/src/VBox/Runtime/VBox/VBoxRTDeps.cpp b/src/VBox/Runtime/VBox/VBoxRTDeps.cpp
index ddfccec..7a003ca 100644
--- a/src/VBox/Runtime/VBox/VBoxRTDeps.cpp
+++ b/src/VBox/Runtime/VBox/VBoxRTDeps.cpp
@@ -76,26 +76,36 @@ PFNRT g_VBoxRTDeps[] =
     (PFNRT)i2d_X509,
     (PFNRT)i2d_X509,
     (PFNRT)i2d_PublicKey,
-    (PFNRT)RSA_generate_key,
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER) || defined(OPENSSL_MANGLER)
+    (PFNRT)RSA_generate_key, /* gsoap */
+#endif
     (PFNRT)RSA_generate_key_ex,
-    (PFNRT)DH_generate_parameters,
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER) || defined(OPENSSL_MANGLER)
+    (PFNRT)DH_generate_parameters, /* gsoap */
+#endif
     (PFNRT)DH_generate_parameters_ex,
     (PFNRT)RAND_load_file,
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
     (PFNRT)CRYPTO_set_dynlock_create_callback,
     (PFNRT)CRYPTO_set_dynlock_lock_callback,
     (PFNRT)CRYPTO_set_dynlock_destroy_callback,
+#endif
     (PFNRT)RTAssertShouldPanic,
     (PFNRT)ASMAtomicReadU64,
     (PFNRT)ASMAtomicCmpXchgU64,
     (PFNRT)ASMBitFirstSet,
     (PFNRT)RTBldCfgRevision,
     (PFNRT)SSL_free,
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
     (PFNRT)SSL_library_init,
     (PFNRT)SSL_load_error_strings,
+#endif
     (PFNRT)SSL_CTX_free,
     (PFNRT)SSL_CTX_use_certificate_file,
     (PFNRT)SSLv23_method,
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
     (PFNRT)TLSv1_server_method,
+#endif
     NULL
 };
 
diff --git a/src/VBox/Runtime/VBox/VBoxRTImp.def b/src/VBox/Runtime/VBox/VBoxRTImp.def
index b7ac81e..a08a4dd 100644
--- a/src/VBox/Runtime/VBox/VBoxRTImp.def
+++ b/src/VBox/Runtime/VBox/VBoxRTImp.def
@@ -793,6 +793,7 @@ EXPORTS
     RTNetUDPChecksum
     RTOnce
     RTOnceReset
+    RTOnceSlow
     RTPathAbs
     RTPathAbsDup
     RTPathAbsEx
diff --git a/src/VBox/Runtime/common/crypto/digest-builtin.cpp b/src/VBox/Runtime/common/crypto/digest-builtin.cpp
index 66b4304..95af4eb 100644
--- a/src/VBox/Runtime/common/crypto/digest-builtin.cpp
+++ b/src/VBox/Runtime/common/crypto/digest-builtin.cpp
@@ -561,7 +561,7 @@ static PCRTCRDIGESTDESC const g_apDigestOps[] =
  * OpenSSL EVP.
  */
 
-# if OPENSSL_VERSION_NUMBER >= 0x10100000
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
 /** @impl_interface_method{RTCRDIGESTDESC::pfnNew} */
 static DECLCALLBACK(void*) rtCrDigestOsslEvp_New(void)
 {
@@ -597,7 +597,7 @@ static DECLCALLBACK(int) rtCrDigestOsslEvp_Init(void *pvState, void *pvOpaque, b
     if (fReInit)
     {
         pEvpType = EVP_MD_CTX_md(pThis);
-# if OPENSSL_VERSION_NUMBER >= 0x10100000
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
         EVP_MD_CTX_reset(pThis);
 # else
         EVP_MD_CTX_cleanup(pThis);
@@ -605,7 +605,11 @@ static DECLCALLBACK(int) rtCrDigestOsslEvp_Init(void *pvState, void *pvOpaque, b
     }
 
     AssertPtrReturn(pEvpType, VERR_INVALID_PARAMETER);
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+    Assert(EVP_MD_block_size(pEvpType));
+# else
     Assert(pEvpType->md_size);
+# endif
     if (EVP_DigestInit(pThis, pEvpType))
         return VINF_SUCCESS;
     return VERR_CR_DIGEST_OSSL_DIGEST_INIT_ERROR;
@@ -616,7 +620,7 @@ static DECLCALLBACK(int) rtCrDigestOsslEvp_Init(void *pvState, void *pvOpaque, b
 static DECLCALLBACK(void) rtCrDigestOsslEvp_Delete(void *pvState)
 {
     EVP_MD_CTX *pThis = (EVP_MD_CTX *)pvState;
-# if OPENSSL_VERSION_NUMBER >= 0x10100000
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
     EVP_MD_CTX_reset(pThis);
 # else
     EVP_MD_CTX_cleanup(pThis);
@@ -661,13 +665,13 @@ static RTCRDIGESTDESC const g_rtCrDigestOpenSslDesc =
     NULL,
     RTDIGESTTYPE_UNKNOWN,
     EVP_MAX_MD_SIZE,
-# if OPENSSL_VERSION_NUMBER >= 0x10100000
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
     0,
 # else
     sizeof(EVP_MD_CTX),
 # endif
     0,
-# if OPENSSL_VERSION_NUMBER >= 0x10100000
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
     rtCrDigestOsslEvp_New,
     rtCrDigestOsslEvp_Free,
 # else
@@ -729,7 +733,11 @@ RTDECL(PCRTCRDIGESTDESC) RTCrDigestFindByObjIdString(const char *pszObjId, void
                 /*
                  * Return the OpenSSL provider descriptor and the EVP_MD address.
                  */
+# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+                Assert(EVP_MD_block_size(pEvpMdType));
+# else
                 Assert(pEvpMdType->md_size);
+# endif
                 *ppvOpaque = (void *)pEvpMdType;
                 return &g_rtCrDigestOpenSslDesc;
             }
diff --git a/src/VBox/Runtime/common/crypto/pkix-verify.cpp b/src/VBox/Runtime/common/crypto/pkix-verify.cpp
index ba537d5..985d619 100644
--- a/src/VBox/Runtime/common/crypto/pkix-verify.cpp
+++ b/src/VBox/Runtime/common/crypto/pkix-verify.cpp
@@ -117,54 +117,82 @@ RTDECL(int) RTCrPkixPubKeyVerifySignature(PCRTASN1OBJID pAlgorithm, PCRTASN1DYNT
     if (iAlgoNid == NID_undef)
         return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN,
                              "Unknown public key algorithm [OpenSSL]: %s", pAlgorithm->szObjId);
-    const char *pszAlogSn = OBJ_nid2sn(iAlgoNid);
-    const EVP_MD *pEvpMdType = EVP_get_digestbyname(pszAlogSn);
+    const char *pszAlgoSn = OBJ_nid2sn(iAlgoNid);
+
+# if OPENSSL_VERSION_NUMBER >= 0x10001000 && !defined(LIBRESSL_VERSION_NUMBER)
+    int idAlgoPkey = 0;
+    int idAlgoMd = 0;
+    if (!OBJ_find_sigid_algs(iAlgoNid, &idAlgoMd, &idAlgoPkey))
+        return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP,
+                             "OBJ_find_sigid_algs failed on %u (%s, %s)", iAlgoNid, pszAlgoSn, pAlgorithm->szObjId);
+    const EVP_MD *pEvpMdType = EVP_get_digestbynid(idAlgoMd);
     if (!pEvpMdType)
         return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP,
-                             "EVP_get_digestbyname failed on %s (%s)", pszAlogSn, pAlgorithm->szObjId);
-
-    /* Initialize the EVP message digest context. */
-    EVP_MD_CTX EvpMdCtx;
-    EVP_MD_CTX_init(&EvpMdCtx);
-    if (!EVP_VerifyInit_ex(&EvpMdCtx, pEvpMdType, NULL /*engine*/))
-        return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALOG_INIT_FAILED,
-                             "EVP_VerifyInit_ex failed (algorithm type is %s / %s)", pszAlogSn, pAlgorithm->szObjId);
+                             "EVP_get_digestbynid failed on %d (%s, %s)", idAlgoMd, pszAlgoSn, pAlgorithm->szObjId);
+# else
+    const EVP_MD *pEvpMdType = EVP_get_digestbyname(pszAlgoSn);
+    if (!pEvpMdType)
+        return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP,
+                             "EVP_get_digestbyname failed on %s (%s)", pszAlgoSn, pAlgorithm->szObjId);
+# endif
 
-    /* Create an EVP public key. */
+    EVP_MD_CTX *pEvpMdCtx = EVP_MD_CTX_create();
+    if (!pEvpMdCtx)
+        return RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "EVP_MD_CTX_create failed");
     int rcOssl;
-    EVP_PKEY *pEvpPublicKey = EVP_PKEY_new();
-    if (pEvpPublicKey)
+    if (EVP_VerifyInit_ex(pEvpMdCtx, pEvpMdType, NULL /*engine*/))
     {
-        pEvpPublicKey->type = EVP_PKEY_type(pEvpMdType->required_pkey_type[0]);
-        if (pEvpPublicKey->type != NID_undef)
+        /* Create an EVP public key. */
+        EVP_PKEY *pEvpPublicKey = EVP_PKEY_new();
+        if (pEvpPublicKey)
         {
-            const unsigned char *puchPublicKey = RTASN1BITSTRING_GET_BIT0_PTR(pPublicKey);
-            if (d2i_PublicKey(pEvpPublicKey->type, &pEvpPublicKey, &puchPublicKey, RTASN1BITSTRING_GET_BYTE_SIZE(pPublicKey)))
+# if OPENSSL_VERSION_NUMBER >= 0x10001000 && !defined(LIBRESSL_VERSION_NUMBER)
+            if (EVP_PKEY_set_type(pEvpPublicKey, idAlgoPkey))
             {
-                /* Digest the data. */
-                EVP_VerifyUpdate(&EvpMdCtx, pvData, cbData);
-
-                /* Verify the signature. */
-                if (EVP_VerifyFinal(&EvpMdCtx,
-                                    RTASN1BITSTRING_GET_BIT0_PTR(pSignatureValue),
-                                    RTASN1BITSTRING_GET_BYTE_SIZE(pSignatureValue),
-                                    pEvpPublicKey) > 0)
-                    rcOssl = VINF_SUCCESS;
+                int idKeyType = EVP_PKEY_base_id(pEvpPublicKey);
+# else
+                int idKeyType = pEvpPublicKey->type = EVP_PKEY_type(pEvpMdType->required_pkey_type[0]);
+# endif
+                if (idKeyType != NID_undef)
+                {
+                    const unsigned char *puchPublicKey = RTASN1BITSTRING_GET_BIT0_PTR(pPublicKey);
+                    if (d2i_PublicKey(idKeyType, &pEvpPublicKey, &puchPublicKey, RTASN1BITSTRING_GET_BYTE_SIZE(pPublicKey)))
+                    {
+                        /* Digest the data. */
+                        EVP_VerifyUpdate(pEvpMdCtx, pvData, cbData);
+
+                        /* Verify the signature. */
+                        if (EVP_VerifyFinal(pEvpMdCtx,
+                                            RTASN1BITSTRING_GET_BIT0_PTR(pSignatureValue),
+                                            RTASN1BITSTRING_GET_BYTE_SIZE(pSignatureValue),
+                                            pEvpPublicKey) > 0)
+                            rcOssl = VINF_SUCCESS;
+                        else
+                            rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_VERIFY_FINAL_FAILED, "EVP_VerifyFinal failed");
+                    }
+                    else
+                        rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_D2I_PUBLIC_KEY_FAILED, "d2i_PublicKey failed");
+                }
                 else
-                    rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_VERIFY_FINAL_FAILED, "EVP_VerifyFinal failed");
+# if OPENSSL_VERSION_NUMBER < 0x10001000 || defined(LIBRESSL_VERSION_NUMBER)
+                    rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR, "EVP_PKEY_type() failed");
+# else
+                    rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR, "EVP_PKEY_base_id() failed");
             }
             else
-                rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_D2I_PUBLIC_KEY_FAILED, "d2i_PublicKey failed");
+                rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR,
+                                       "EVP_PKEY_set_type(%u) failed (sig algo %s)", idAlgoPkey, pszAlgoSn);
+# endif
+            /* Cleanup and return.*/
+            EVP_PKEY_free(pEvpPublicKey);
         }
         else
-            rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR,
-                                   "EVP_PKEY_type(%d) failed", pEvpMdType->required_pkey_type[0]);
-        /* Cleanup and return.*/
-        EVP_PKEY_free(pEvpPublicKey);
+            rcOssl = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "EVP_PKEY_new(%d) failed", iAlgoNid);
     }
     else
-        rcOssl = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "EVP_PKEY_new(%d) failed", pEvpMdType->required_pkey_type[0]);
-    EVP_MD_CTX_cleanup(&EvpMdCtx);
+        rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALOG_INIT_FAILED,
+                               "EVP_VerifyInit_ex failed (algorithm type is %s / %s)", pszAlgoSn, pAlgorithm->szObjId);
+    EVP_MD_CTX_destroy(pEvpMdCtx);
 
     /*
      * Check the result.
@@ -250,68 +278,96 @@ RTDECL(int) RTCrPkixPubKeyVerifySignedDigest(PCRTASN1OBJID pAlgorithm, PCRTASN1D
     if (iAlgoNid == NID_undef)
         return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN,
                              "Unknown public key algorithm [OpenSSL]: %s", pszAlgObjId);
-    const char *pszAlogSn = OBJ_nid2sn(iAlgoNid);
-    const EVP_MD *pEvpMdType = EVP_get_digestbyname(pszAlogSn);
+    const char *pszAlgoSn = OBJ_nid2sn(iAlgoNid);
+
+# if OPENSSL_VERSION_NUMBER >= 0x10001000 && !defined(LIBRESSL_VERSION_NUMBER)
+    int idAlgoPkey = 0;
+    int idAlgoMd = 0;
+    if (!OBJ_find_sigid_algs(iAlgoNid, &idAlgoMd, &idAlgoPkey))
+        return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP,
+                             "OBJ_find_sigid_algs failed on %u (%s, %s)", iAlgoNid, pszAlgoSn, pAlgorithm->szObjId);
+    const EVP_MD *pEvpMdType = EVP_get_digestbynid(idAlgoMd);
     if (!pEvpMdType)
         return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP,
-                             "EVP_get_digestbyname failed on %s (%s)", pszAlogSn, pszAlgObjId);
+                             "EVP_get_digestbynid failed on %d (%s, %s)", idAlgoMd, pszAlgoSn, pAlgorithm->szObjId);
+# else
+    const EVP_MD *pEvpMdType = EVP_get_digestbyname(pszAlgoSn);
+    if (!pEvpMdType)
+        return RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP,
+                             "EVP_get_digestbyname failed on %s (%s)", pszAlgoSn, pszAlgObjId);
+# endif
 
     /* Create an EVP public key. */
     int rcOssl;
     EVP_PKEY *pEvpPublicKey = EVP_PKEY_new();
     if (pEvpPublicKey)
     {
-        pEvpPublicKey->type = EVP_PKEY_type(pEvpMdType->required_pkey_type[0]);
-        if (pEvpPublicKey->type != NID_undef)
+# if OPENSSL_VERSION_NUMBER >= 0x10001000 && !defined(LIBRESSL_VERSION_NUMBER)
+        if (EVP_PKEY_set_type(pEvpPublicKey, idAlgoPkey))
         {
-            const unsigned char *puchPublicKey = RTASN1BITSTRING_GET_BIT0_PTR(pPublicKey);
-            if (d2i_PublicKey(pEvpPublicKey->type, &pEvpPublicKey, &puchPublicKey, RTASN1BITSTRING_GET_BYTE_SIZE(pPublicKey)))
+            int idKeyType = EVP_PKEY_base_id(pEvpPublicKey);
+# else
+            int idKeyType = pEvpPublicKey->type = EVP_PKEY_type(pEvpMdType->required_pkey_type[0]);
+# endif
+            if (idKeyType != NID_undef)
+
             {
-                /* Create an EVP public key context we can use to validate the digest. */
-                EVP_PKEY_CTX *pEvpPKeyCtx = EVP_PKEY_CTX_new(pEvpPublicKey, NULL);
-                if (pEvpPKeyCtx)
+                const unsigned char *puchPublicKey = RTASN1BITSTRING_GET_BIT0_PTR(pPublicKey);
+                if (d2i_PublicKey(idKeyType, &pEvpPublicKey, &puchPublicKey, RTASN1BITSTRING_GET_BYTE_SIZE(pPublicKey)))
                 {
-                    rcOssl = EVP_PKEY_verify_init(pEvpPKeyCtx);
-                    if (rcOssl > 0)
+                    /* Create an EVP public key context we can use to validate the digest. */
+                    EVP_PKEY_CTX *pEvpPKeyCtx = EVP_PKEY_CTX_new(pEvpPublicKey, NULL);
+                    if (pEvpPKeyCtx)
                     {
-                        rcOssl = EVP_PKEY_CTX_set_signature_md(pEvpPKeyCtx, pEvpMdType);
+                        rcOssl = EVP_PKEY_verify_init(pEvpPKeyCtx);
                         if (rcOssl > 0)
                         {
-                            /* Get the digest from hDigest and verify it. */
-                            rcOssl = EVP_PKEY_verify(pEvpPKeyCtx,
-                                                     (uint8_t const *)pvSignedDigest,
-                                                     cbSignedDigest,
-                                                     RTCrDigestGetHash(hDigest),
-                                                     RTCrDigestGetHashSize(hDigest));
+                            rcOssl = EVP_PKEY_CTX_set_signature_md(pEvpPKeyCtx, pEvpMdType);
                             if (rcOssl > 0)
-                                rcOssl = VINF_SUCCESS;
+                            {
+                                /* Get the digest from hDigest and verify it. */
+                                rcOssl = EVP_PKEY_verify(pEvpPKeyCtx,
+                                                         (uint8_t const *)pvSignedDigest,
+                                                         cbSignedDigest,
+                                                         RTCrDigestGetHash(hDigest),
+                                                         RTCrDigestGetHashSize(hDigest));
+                                if (rcOssl > 0)
+                                    rcOssl = VINF_SUCCESS;
+                                else
+                                    rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_VERIFY_FINAL_FAILED,
+                                                           "EVP_PKEY_verify failed (%d)", rcOssl);
+                            }
                             else
-                                rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_VERIFY_FINAL_FAILED,
-                                                       "EVP_PKEY_verify failed (%d)", rcOssl);
+                                rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR,
+                                                       "EVP_PKEY_CTX_set_signature_md failed (%d)", rcOssl);
                         }
                         else
                             rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR,
-                                                   "EVP_PKEY_CTX_set_signature_md failed (%d)", rcOssl);
+                                                   "EVP_PKEY_verify_init failed (%d)", rcOssl);
+                        EVP_PKEY_CTX_free(pEvpPKeyCtx);
                     }
                     else
-                        rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR,
-                                               "EVP_PKEY_verify_init failed (%d)", rcOssl);
-                    EVP_PKEY_CTX_free(pEvpPKeyCtx);
+                        rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR, "EVP_PKEY_CTX_new failed");
                 }
                 else
-                    rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR, "EVP_PKEY_CTX_new failed");
+                    rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_D2I_PUBLIC_KEY_FAILED, "d2i_PublicKey failed");
             }
             else
-                rcOssl = RTErrInfoSet(pErrInfo, VERR_CR_PKIX_OSSL_D2I_PUBLIC_KEY_FAILED, "d2i_PublicKey failed");
+# if OPENSSL_VERSION_NUMBER < 0x10001000 || defined(LIBRESSL_VERSION_NUMBER)
+                rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR, "EVP_PKEY_type() failed");
+# else
+                rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR, "EVP_PKEY_base_id() failed");
         }
         else
             rcOssl = RTErrInfoSetF(pErrInfo, VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR,
-                                   "EVP_PKEY_type(%d) failed", pEvpMdType->required_pkey_type[0]);
+                                   "EVP_PKEY_set_type(%u) failed (sig algo %s)", idAlgoPkey, pszAlgoSn);
+# endif
+
         /* Cleanup and return.*/
         EVP_PKEY_free(pEvpPublicKey);
     }
     else
-        rcOssl = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "EVP_PKEY_new(%d) failed", pEvpMdType->required_pkey_type[0]);
+        rcOssl = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "EVP_PKEY_new(%d) failed", iAlgoNid);
 
     /*
      * Check the result.
diff --git a/src/VBox/Runtime/common/ldr/ldrPE.cpp b/src/VBox/Runtime/common/ldr/ldrPE.cpp
index cc03623..fdd9124 100644
--- a/src/VBox/Runtime/common/ldr/ldrPE.cpp
+++ b/src/VBox/Runtime/common/ldr/ldrPE.cpp
@@ -2971,8 +2971,8 @@ static void rtldrPEConvert32BitLoadConfigTo64Bit(PIMAGE_LOAD_CONFIG_DIRECTORY64
     /*
      * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff.
      */
-    IMAGE_LOAD_CONFIG_DIRECTORY32_V5 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V5 volatile *)pLoadCfg;
-    IMAGE_LOAD_CONFIG_DIRECTORY64_V5 volatile *pLoadCfg64 = pLoadCfg;
+    IMAGE_LOAD_CONFIG_DIRECTORY32_V7 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V7 volatile *)pLoadCfg;
+    IMAGE_LOAD_CONFIG_DIRECTORY64_V7 volatile *pLoadCfg64 = pLoadCfg;
 
     pLoadCfg64->GuardAddressTakenIatEntryTable  = pLoadCfg32->GuardAddressTakenIatEntryTable;
     pLoadCfg64->GuardAddressTakenIatEntryCount  = pLoadCfg32->GuardAddressTakenIatEntryCount;
@@ -2985,13 +2985,13 @@ static void rtldrPEConvert32BitLoadConfigTo64Bit(PIMAGE_LOAD_CONFIG_DIRECTORY64
     pLoadCfg64->GuardFlags                      = pLoadCfg32->GuardFlags;
     pLoadCfg64->GuardCFFunctionCount            = pLoadCfg32->GuardCFFunctionCount;
     pLoadCfg64->GuardCFFunctionTable            = pLoadCfg32->GuardCFFunctionTable;
-    pLoadCfg64->Reserved2                       = pLoadCfg32->Reserved2;
+    pLoadCfg64->GuardCFDispatchFunctionPointer  = pLoadCfg32->GuardCFDispatchFunctionPointer;
     pLoadCfg64->GuardCFCCheckFunctionPointer    = pLoadCfg32->GuardCFCCheckFunctionPointer;
     pLoadCfg64->SEHandlerCount                  = pLoadCfg32->SEHandlerCount;
     pLoadCfg64->SEHandlerTable                  = pLoadCfg32->SEHandlerTable;
     pLoadCfg64->SecurityCookie                  = pLoadCfg32->SecurityCookie;
     pLoadCfg64->EditList                        = pLoadCfg32->EditList;
-    pLoadCfg64->Reserved1                       = pLoadCfg32->Reserved1;
+    pLoadCfg64->DependentLoadFlags              = pLoadCfg32->DependentLoadFlags;
     pLoadCfg64->CSDVersion                      = pLoadCfg32->CSDVersion;
     pLoadCfg64->ProcessHeapFlags                = pLoadCfg32->ProcessHeapFlags; /* switched place with ProcessAffinityMask, but we're more than 16 byte off by now so it doesn't matter. */
     pLoadCfg64->ProcessAffinityMask             = pLoadCfg32->ProcessAffinityMask;
@@ -3517,7 +3517,7 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
     union /* combine stuff we're reading to help reduce stack usage. */
     {
         IMAGE_LOAD_CONFIG_DIRECTORY64   Cfg64;
-        uint8_t                         abZeros[sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V5) * 4];
+        uint8_t                         abZeros[sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V7) * 4];
     } u;
 
     /*
@@ -3528,6 +3528,12 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
     IMAGE_DATA_DIRECTORY Dir = pOptHdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG];
     if (Dir.Size)
     {
+        const size_t cbExpectV7 = !pModPe->f64Bit
+                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V7)
+                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V7);
+        const size_t cbExpectV6 = !pModPe->f64Bit
+                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V6)
+                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V6);
         const size_t cbExpectV5 = !pModPe->f64Bit
                                 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V5)
                                 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V5);
@@ -3543,23 +3549,27 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
         const size_t cbExpectV1 = !pModPe->f64Bit
                                 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V1)
                                 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/;
+        const size_t cbNewHack  = cbExpectV5; /* Playing safe here since there might've been revisions between V5 and V6 we don't know about . */
+        const size_t cbMaxKnown = cbExpectV7;
 
         bool fNewerStructureHack = false;
-        if (   Dir.Size != cbExpectV5
+        if (   Dir.Size != cbExpectV7
+            && Dir.Size != cbExpectV6
+            && Dir.Size != cbExpectV5
             && Dir.Size != cbExpectV4
             && Dir.Size != cbExpectV3
             && Dir.Size != cbExpectV2
             && Dir.Size != cbExpectV1)
         {
-            fNewerStructureHack = Dir.Size > cbExpectV5  /* These structure changes are slowly getting to us! More futher down. */
+            fNewerStructureHack = Dir.Size > cbNewHack /* These structure changes are slowly getting to us! More futher down. */
                                && Dir.Size <= sizeof(u);
-            Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, or %zu.%s\n",
-                 pszLogName, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
+            Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n",
+                 pszLogName, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
                  fNewerStructureHack ? " Will try ignore extra bytes if all zero." : ""));
             if (!fNewerStructureHack)
                 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
-                                     "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, or %zu",
-                                     Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
+                                     "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
+                                     Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
         }
 
         /*
@@ -3575,13 +3585,14 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
         if (RT_FAILURE(rc))
             return rc;
         if (   fNewerStructureHack
-            && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5))
+            && Dir.Size > cbMaxKnown
+            && !ASMMemIsZero(&u.abZeros[cbMaxKnown], Dir.Size - cbMaxKnown))
         {
             Log(("rtldrPEOpen: %s: load cfg dir: Unexpected bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n",
-                 pszLogName, Dir.Size, Dir.Size - cbExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]));
+                 pszLogName, Dir.Size, Dir.Size - cbMaxKnown, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown]));
             return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
                                  "Grown load config (%u to %u bytes) includes non-zero bytes: %.*Rhxs",
-                                 cbExpectV5, Dir.Size, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]);
+                                 cbMaxKnown, Dir.Size, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown]);
         }
         rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64);
 
@@ -3596,12 +3607,14 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
             }
             /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get
                updated and stores some old size in the directory.  Use the header size. */
-            else if (   u.Cfg64.Size == cbExpectV5
+            else if (   u.Cfg64.Size == cbExpectV7
+                     || u.Cfg64.Size == cbExpectV6
+                     || u.Cfg64.Size == cbExpectV5
                      || u.Cfg64.Size == cbExpectV4
                      || u.Cfg64.Size == cbExpectV3
                      || u.Cfg64.Size == cbExpectV2
                      || u.Cfg64.Size == cbExpectV1
-                     || (fNewerStructureHack = (u.Cfg64.Size > cbExpectV5 && u.Cfg64.Size <= sizeof(u))) )
+                     || (fNewerStructureHack = (u.Cfg64.Size > cbNewHack && u.Cfg64.Size <= sizeof(u))) )
             {
                 Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the old linker kludge.\n",
                      pszLogName, u.Cfg64.Size, Dir.Size));
@@ -3613,13 +3626,14 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
                 if (RT_FAILURE(rc))
                     return rc;
                 if (   fNewerStructureHack
-                    && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5))
+                    && Dir.Size > cbMaxKnown
+                    && !ASMMemIsZero(&u.abZeros[cbMaxKnown], Dir.Size - cbMaxKnown))
                 {
                     Log(("rtldrPEOpen: %s: load cfg dir: Unknown bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n",
-                         pszLogName, Dir.Size, Dir.Size - cbExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]));
+                         pszLogName, Dir.Size, Dir.Size - cbMaxKnown, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown]));
                     return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
                                          "Grown load config (%u to %u bytes, dir %u) includes non-zero bytes: %.*Rhxs",
-                                         cbExpectV5, Dir.Size, uOrgDir, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]);
+                                         cbMaxKnown, Dir.Size, uOrgDir, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown]);
                 }
                 rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64);
                 AssertReturn(u.Cfg64.Size == Dir.Size,
@@ -3628,11 +3642,11 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
             }
             else
             {
-                Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, or %zu.\n",
-                     pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
+                Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, %zu, %zu, or %zu.\n",
+                     pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
                 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
-                                     "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, or %zu",
-                                     u.Cfg64.Size, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
+                                     "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
+                                     u.Cfg64.Size, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
             }
         }
         if (u.Cfg64.LockPrefixTable && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION)))
@@ -3662,7 +3676,7 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
          * Not trusting something designed by bakas who don't know how to modify a
          * structure without messing up its natural alignment. */
         if (    (   u.Cfg64.GuardCFCCheckFunctionPointer
-                 || u.Cfg64.Reserved2
+                 || u.Cfg64.GuardCFDispatchFunctionPointer
                  || u.Cfg64.GuardCFFunctionTable
                  || u.Cfg64.GuardCFFunctionCount
                  || u.Cfg64.GuardFlags
@@ -3673,13 +3687,13 @@ static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const
             && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION)) )
         {
             Log(("rtldrPEOpen: %s: load cfg dir: Guard stuff: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!\n",
-                 pszLogName, u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.Reserved2,
+                 pszLogName, u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.GuardCFDispatchFunctionPointer,
                  u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags,
                  u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount,
                  u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount ));
             return RTErrInfoSetF(pErrInfo, VERR_LDRPE_GUARD_CF_STUFF,
                                  "Guard bits in load config: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!",
-                                 u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.Reserved2,
+                                 u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.GuardCFDispatchFunctionPointer,
                                  u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags,
                                  u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount,
                                  u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount);
diff --git a/src/VBox/Runtime/common/misc/lockvalidator.cpp b/src/VBox/Runtime/common/misc/lockvalidator.cpp
index bdf6273..22ef076 100644
--- a/src/VBox/Runtime/common/misc/lockvalidator.cpp
+++ b/src/VBox/Runtime/common/misc/lockvalidator.cpp
@@ -583,7 +583,7 @@ DECL_FORCE_INLINE(void) rtLockValComplainAboutLockHlp(const char *pszPrefix, PRT
         case RTLOCKVALRECEXCL_MAGIC:
 #ifdef RTLOCKVAL_WITH_VERBOSE_DUMPS
             RTAssertMsg2AddWeak("%s%p %s xrec=%p own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [x%s]%s", pszPrefix,
-                                pRec->Excl.hLock, pRec->Excl.pszName, pRec,
+                                pRec->Excl.hLock, pRec->Excl.szName, pRec,
                                 rtLockValidatorNameThreadHandle(&pRec->Excl.hThread), cRecursion,
                                 rtLockValComplainGetClassName(pRec->Excl.hClass),
                                 rtLockValComplainGetSubClassName(pRec->Excl.uSubClass, szBuf),
@@ -615,12 +615,12 @@ DECL_FORCE_INLINE(void) rtLockValComplainAboutLockHlp(const char *pszPrefix, PRT
                 &&  pShared->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC)
 #ifdef RTLOCKVAL_WITH_VERBOSE_DUMPS
                 RTAssertMsg2AddWeak("%s%p %s srec=%p trec=%p own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [o%s]%s", pszPrefix,
-                                    pShared->hLock, pShared->pszName, pShared,
+                                    pShared->hLock, pShared->szName, pShared,
                                     pRec, rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion,
                                     rtLockValComplainGetClassName(pShared->hClass),
                                     rtLockValComplainGetSubClassName(pShared->uSubClass, szBuf),
                                     pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId,
-                                    pszSuffix2, pszSuffix);
+                                    pszSuffix, pszSuffix);
 #else
                 RTAssertMsg2AddWeak("%s%p %s own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [o%s]%s", pszPrefix,
                                     pShared->hLock, pShared->szName,
diff --git a/src/VBox/Runtime/common/time/timesup.cpp b/src/VBox/Runtime/common/time/timesup.cpp
index 34652a9..aa31aa1 100644
--- a/src/VBox/Runtime/common/time/timesup.cpp
+++ b/src/VBox/Runtime/common/time/timesup.cpp
@@ -202,6 +202,8 @@ static DECLCALLBACK(uint64_t) rtTimeNanoTSInternalRediscover(PRTTIMENANOTSDATA p
                           ? RTTimeNanoTSLFenceAsyncUseIdtrLim
                           : pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
                           ? RTTimeNanoTSLFenceAsyncUseRdtscp
+                          : pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
+                          ? RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl
                           : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID
                           ? RTTimeNanoTSLFenceAsyncUseApicId
                           : rtTimeNanoTSInternalFallback;
@@ -238,6 +240,8 @@ static DECLCALLBACK(uint64_t) rtTimeNanoTSInternalRediscover(PRTTIMENANOTSDATA p
             if (pGip->u32Mode == SUPGIPMODE_ASYNC_TSC)
                 pfnWorker = pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
                           ? RTTimeNanoTSLegacyAsyncUseRdtscp
+                          : pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
+                          ? RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl
                           : pGip->fGetGipCpu & SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS
                           ? RTTimeNanoTSLegacyAsyncUseIdtrLim
                           : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID
diff --git a/src/VBox/Runtime/common/time/timesupref.cpp b/src/VBox/Runtime/common/time/timesupref.cpp
index 5d87827..e5dd553 100644
--- a/src/VBox/Runtime/common/time/timesupref.cpp
+++ b/src/VBox/Runtime/common/time/timesupref.cpp
@@ -36,6 +36,7 @@
 #include <iprt/asm.h>
 #include <iprt/asm-math.h>
 #include <iprt/asm-amd64-x86.h>
+#include <iprt/param.h>
 #include <VBox/sup.h>
 #ifdef IN_RC
 # include <VBox/vmm/vmm.h>
@@ -111,6 +112,13 @@ RT_EXPORT_SYMBOL(RTTimeNanoTSLegacyAsyncUseRdtscp);
 # include "timesupref.h"
 RT_EXPORT_SYMBOL(RTTimeNanoTSLegacyAsyncUseIdtrLim);
 
+# undef  TMPL_GET_CPU_METHOD
+# define TMPL_GET_CPU_METHOD     SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
+# undef  rtTimeNanoTSInternalRef
+# define rtTimeNanoTSInternalRef RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl
+# include "timesupref.h"
+RT_EXPORT_SYMBOL(RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl);
+
 #else  /* IN_RC || IN_RING0: Disable interrupts and call getter function. */
 
 # undef  TMPL_MODE
@@ -195,6 +203,13 @@ RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceAsyncUseRdtscp);
 # include "timesupref.h"
 RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceAsyncUseIdtrLim);
 
+# undef  TMPL_GET_CPU_METHOD
+# define TMPL_GET_CPU_METHOD     SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
+# undef  rtTimeNanoTSInternalRef
+# define rtTimeNanoTSInternalRef RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl
+# include "timesupref.h"
+RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl);
+
 #else  /* IN_RC || IN_RING0: Disable interrupts and call getter function. */
 
 # undef  TMPL_MODE
diff --git a/src/VBox/Runtime/common/time/timesupref.h b/src/VBox/Runtime/common/time/timesupref.h
index 4219506..c59c1cb 100644
--- a/src/VBox/Runtime/common/time/timesupref.h
+++ b/src/VBox/Runtime/common/time/timesupref.h
@@ -90,13 +90,26 @@ RTDECL(uint64_t) rtTimeNanoTSInternalRef(PRTTIMENANOTSDATA pData)
 #  endif
             uint8_t  const  idApic   = ASMGetApicId();
             uint16_t const  iGipCpu  = pGip->aiCpuFromApicId[idApic];
-# elif TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
+# elif TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS \
+    || TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
 #  if TMPL_MODE != TMPL_MODE_ASYNC
             uint32_t const  u32TransactionId = pGip->aCPUs[0].u32TransactionId;
 #  endif
             uint32_t        uAux;
             ASMReadTscWithAux(&uAux);
+#  if TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
             uint16_t const  iCpuSet  = uAux & (RTCPUSET_MAX_CPUS - 1);
+#  else
+            uint16_t        iCpuSet = 0;
+            uint16_t        offGipCpuGroup = pGip->aoffCpuGroup[(uAux >> 8) & UINT8_MAX];
+            if (offGipCpuGroup < pGip->cPages * PAGE_SIZE)
+            {
+                PSUPGIPCPUGROUP pGipCpuGroup = (PSUPGIPCPUGROUP)((uintptr_t)pGip + offGipCpuGroup);
+                if (   (uAux & UINT8_MAX) < pGipCpuGroup->cMaxMembers
+                    && pGipCpuGroup->aiCpuSetIdxs[uAux & UINT8_MAX] != -1)
+                    iCpuSet = pGipCpuGroup->aiCpuSetIdxs[uAux & UINT8_MAX];
+            }
+#  endif
             uint16_t const  iGipCpu  = pGip->aiCpuFromCpuSetIdx[iCpuSet];
 # elif TMPL_GET_CPU_METHOD == SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS
             uint16_t const  cbLim    = ASMGetIdtrLimit();
@@ -123,7 +136,8 @@ RTDECL(uint64_t) rtTimeNanoTSInternalRef(PRTTIMENANOTSDATA pData)
                 TMPL_READ_FENCE();
 #elif TMPL_MODE != TMPL_MODE_ASYNC \
    && TMPL_GET_CPU_METHOD != SUPGIPGETCPU_APIC_ID \
-   && TMPL_GET_CPU_METHOD != SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
+   && TMPL_GET_CPU_METHOD != SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS \
+   && TMPL_GET_CPU_METHOD != SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
                 uint32_t const u32TransactionId = pGip->aCPUs[0].u32TransactionId;
                 ASMCompilerBarrier();
                 TMPL_READ_FENCE();
@@ -148,7 +162,8 @@ RTDECL(uint64_t) rtTimeNanoTSInternalRef(PRTTIMENANOTSDATA pData)
 # endif
 #endif
                 uint64_t u64PrevNanoTS          = ASMAtomicUoReadU64(pData->pu64Prev);
-#if TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
+#if TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS \
+ || TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
                 ASMCompilerBarrier();
                 uint32_t uAux2;
                 uint64_t u64Delta               = ASMReadTscWithAux(&uAux2); /* serializing */
@@ -167,7 +182,8 @@ RTDECL(uint64_t) rtTimeNanoTSInternalRef(PRTTIMENANOTSDATA pData)
 #if defined(IN_RING3) && ( TMPL_MODE == TMPL_MODE_ASYNC || TMPL_MODE == TMPL_MODE_SYNC_INVAR_WITH_DELTA )
 # if   TMPL_GET_CPU_METHOD == SUPGIPGETCPU_APIC_ID
                 if (RT_LIKELY(ASMGetApicId() == idApic))
-# elif TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
+# elif TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS \
+    || TMPL_GET_CPU_METHOD == SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
                 if (RT_LIKELY(uAux2 == uAux))
 # elif TMPL_GET_CPU_METHOD == SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS
                 if (RT_LIKELY(ASMGetIdtrLimit() == cbLim))
diff --git a/src/VBox/Runtime/generic/mppresent-generic-online.cpp b/src/VBox/Runtime/generic/mppresent-generic-online.cpp
new file mode 100644
index 0000000..0a59b16
--- /dev/null
+++ b/src/VBox/Runtime/generic/mppresent-generic-online.cpp
@@ -0,0 +1,61 @@
+/* $Id: mppresent-generic-online.cpp $ */
+/** @file
+ * IPRT - Multiprocessor, Stubs for the RTMp*Present* API mapping to RTMp*Online.
+ */
+
+/*
+ * Copyright (C) 2008-2016 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include <iprt/mp.h>
+#include "internal/iprt.h"
+
+
+RTDECL(PRTCPUSET) RTMpGetPresentSet(PRTCPUSET pSet)
+{
+    return RTMpGetOnlineSet(pSet);
+}
+RT_EXPORT_SYMBOL(RTMpGetPresentSet);
+
+
+RTDECL(RTCPUID) RTMpGetPresentCount(void)
+{
+    return RTMpGetOnlineCount();
+}
+RT_EXPORT_SYMBOL(RTMpGetPresentCount);
+
+
+RTDECL(RTCPUID) RTMpGetPresentCoreCount(void)
+{
+    return RTMpGetOnlineCoreCount();
+}
+RT_EXPORT_SYMBOL(RTMpGetPresentCoreCount);
+
+
+RTDECL(bool) RTMpIsCpuPresent(RTCPUID idCpu)
+{
+    return RTMpIsCpuOnline(idCpu);
+}
+RT_EXPORT_SYMBOL(RTMpIsCpuPresent);
+
diff --git a/src/VBox/Runtime/include/internal/mp.h b/src/VBox/Runtime/include/internal/mp.h
new file mode 100644
index 0000000..8b9786f
--- /dev/null
+++ b/src/VBox/Runtime/include/internal/mp.h
@@ -0,0 +1,82 @@
+/* $Id: mp.h $ */
+/** @file
+ * IPRT - Internal RTMp header
+ */
+
+/*
+ * Copyright (C) 2016 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___internal_mp_h
+#define ___internal_mp_h
+
+#include <iprt/assert.h>
+#include <iprt/mp.h>
+
+RT_C_DECLS_BEGIN
+
+
+#ifdef RT_OS_WINDOWS
+/** @todo Return the processor group + number instead.
+ * Unfortunately, DTrace and HM makes the impossible for the time being as it
+ * seems to be making the stupid assumption that idCpu == iCpuSet. */
+#if 0
+# define IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+#endif
+
+# ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+
+/** @def RTMPCPUID_FROM_GROUP_AND_NUMBER
+ * Creates the RTCPUID value.
+ *
+ * @remarks We Increment a_uGroup by 1 to make sure the ID is never the same as
+ *          the CPU set index.
+ *
+ * @remarks We put the group in the top to make it easy to construct the MAX ID.
+ *          For that reason we also just use 8 bits for the processor number, as
+ *          it keeps the range small.
+ */
+#  define RTMPCPUID_FROM_GROUP_AND_NUMBER(a_uGroup, a_uGroupMember)  \
+    ( (uint8_t)(a_uGroupMember) | (((uint32_t)(a_uGroup) + 1) << 8) )
+
+/** Extracts the group number from a RTCPUID value.  */
+DECLINLINE(uint16_t) rtMpCpuIdGetGroup(RTCPUID idCpu)
+{
+    Assert(idCpu != NIL_RTCPUID);
+    uint16_t idxGroup = idCpu >> 8;
+    Assert(idxGroup != 0);
+    return idxGroup - 1;
+}
+
+/** Extracts the group member number from a RTCPUID value.   */
+DECLINLINE(uint8_t) rtMpCpuIdGetGroupMember(RTCPUID idCpu)
+{
+    Assert(idCpu != NIL_RTCPUID);
+    return (uint8_t)idCpu;
+}
+
+# endif /* IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER */
+#endif /* RT_OS_WINDOWS */
+
+
+RT_C_DECLS_END
+
+#endif
+
diff --git a/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c
index 5b37881..ec2a83b 100644
--- a/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c
+++ b/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c
@@ -38,6 +38,11 @@
 #include <iprt/thread.h>
 #include "r0drv/mp-r0drv.h"
 
+#ifdef nr_cpumask_bits
+# define VBOX_NR_CPUMASK_BITS   nr_cpumask_bits
+#else
+# define VBOX_NR_CPUMASK_BITS   NR_CPUS
+#endif
 
 RTDECL(RTCPUID) RTMpCpuId(void)
 {
@@ -62,21 +67,21 @@ RT_EXPORT_SYMBOL(RTMpCurSetIndexAndId);
 
 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
 {
-    return idCpu < RTCPUSET_MAX_CPUS && idCpu < NR_CPUS ? (int)idCpu : -1;
+    return idCpu < RTCPUSET_MAX_CPUS && idCpu < VBOX_NR_CPUMASK_BITS ? (int)idCpu : -1;
 }
 RT_EXPORT_SYMBOL(RTMpCpuIdToSetIndex);
 
 
 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
 {
-    return iCpu < NR_CPUS ? (RTCPUID)iCpu : NIL_RTCPUID;
+    return iCpu < VBOX_NR_CPUMASK_BITS ? (RTCPUID)iCpu : NIL_RTCPUID;
 }
 RT_EXPORT_SYMBOL(RTMpCpuIdFromSetIndex);
 
 
 RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
 {
-    return NR_CPUS - 1; //???
+    return VBOX_NR_CPUMASK_BITS - 1; //???
 }
 RT_EXPORT_SYMBOL(RTMpGetMaxCpuId);
 
@@ -84,7 +89,7 @@ RT_EXPORT_SYMBOL(RTMpGetMaxCpuId);
 RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
 {
 #if defined(CONFIG_SMP)
-    if (RT_UNLIKELY(idCpu >= NR_CPUS))
+    if (RT_UNLIKELY(idCpu >= VBOX_NR_CPUMASK_BITS))
         return false;
 
 # if defined(cpu_possible)
@@ -139,7 +144,7 @@ RT_EXPORT_SYMBOL(RTMpGetCount);
 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
 {
 #ifdef CONFIG_SMP
-    if (RT_UNLIKELY(idCpu >= NR_CPUS))
+    if (RT_UNLIKELY(idCpu >= VBOX_NR_CPUMASK_BITS))
         return false;
 # ifdef cpu_online
     return cpu_online(idCpu);
diff --git a/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp b/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp
index 17fa5d7..494d94b 100644
--- a/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp
+++ b/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp
@@ -30,9 +30,7 @@
 *********************************************************************************************************************************/
 #include "the-nt-kernel.h"
 #include <iprt/asm-amd64-x86.h>
-#include <iprt/assert.h>
 #include <iprt/err.h>
-#include <iprt/mp.h>
 #include <iprt/string.h>
 #include "internal/initterm.h"
 #include "internal-r0drv-nt.h"
@@ -43,52 +41,67 @@
 /*********************************************************************************************************************************
 *   Global Variables                                                                                                             *
 *********************************************************************************************************************************/
-/** The NT CPU set.
- * KeQueryActiveProcssors() cannot be called at all IRQLs and therefore we'll
- * have to cache it. Fortunately, Nt doesn't really support taking CPUs offline
- * or online. It's first with W2K8 that support for CPU hotplugging was added.
- * Once we start caring about this, we'll simply let the native MP event callback
- * and update this variable as CPUs comes online. (The code is done already.)
- */
-RTCPUSET                            g_rtMpNtCpuSet;
-
 /** ExSetTimerResolution, introduced in W2K. */
-PFNMYEXSETTIMERRESOLUTION           g_pfnrtNtExSetTimerResolution;
+PFNMYEXSETTIMERRESOLUTION               g_pfnrtNtExSetTimerResolution;
 /** KeFlushQueuedDpcs, introduced in XP. */
-PFNMYKEFLUSHQUEUEDDPCS              g_pfnrtNtKeFlushQueuedDpcs;
+PFNMYKEFLUSHQUEUEDDPCS                  g_pfnrtNtKeFlushQueuedDpcs;
 /** HalRequestIpi, version introduced with windows 7. */
-PFNHALREQUESTIPI_W7PLUS             g_pfnrtHalRequestIpiW7Plus;
+PFNHALREQUESTIPI_W7PLUS                 g_pfnrtHalRequestIpiW7Plus;
 /** HalRequestIpi, version valid up to windows vista?? */
-PFNHALREQUESTIPI_PRE_W7             g_pfnrtHalRequestIpiPreW7;
+PFNHALREQUESTIPI_PRE_W7                 g_pfnrtHalRequestIpiPreW7;
 /** Worker for RTMpPokeCpu. */
-PFNRTSENDIPI                        g_pfnrtMpPokeCpuWorker;
+PFNRTSENDIPI                            g_pfnrtMpPokeCpuWorker;
 /** KeIpiGenericCall - Introduced in Windows Server 2003. */
-PFNRTKEIPIGENERICCALL               g_pfnrtKeIpiGenericCall;
+PFNRTKEIPIGENERICCALL                   g_pfnrtKeIpiGenericCall;
+/** KeSetTargetProcessorDpcEx - Introduced in Windows 7. */
+PFNKESETTARGETPROCESSORDPCEX            g_pfnrtKeSetTargetProcessorDpcEx;
 /** KeInitializeAffinityEx - Introducted in Windows 7. */
-PFNKEINITIALIZEAFFINITYEX           g_pfnrtKeInitializeAffinityEx;
+PFNKEINITIALIZEAFFINITYEX               g_pfnrtKeInitializeAffinityEx;
 /** KeAddProcessorAffinityEx - Introducted in Windows 7. */
-PFNKEADDPROCESSORAFFINITYEX         g_pfnrtKeAddProcessorAffinityEx;
-/** KeGetProcessorIndexFromNumber - Introducted in Windows  7. */
-PFNKEGETPROCESSORINDEXFROMNUMBER    g_pfnrtKeGetProcessorIndexFromNumber;
+PFNKEADDPROCESSORAFFINITYEX             g_pfnrtKeAddProcessorAffinityEx;
+/** KeGetProcessorIndexFromNumber - Introducted in Windows 7. */
+PFNKEGETPROCESSORINDEXFROMNUMBER        g_pfnrtKeGetProcessorIndexFromNumber;
+/** KeGetProcessorNumberFromIndex - Introducted in Windows 7. */
+PFNKEGETPROCESSORNUMBERFROMINDEX        g_pfnrtKeGetProcessorNumberFromIndex;
+/** KeGetCurrentProcessorNumberEx - Introducted in Windows 7. */
+PFNKEGETCURRENTPROCESSORNUMBEREX        g_pfnrtKeGetCurrentProcessorNumberEx;
+/** KeQueryActiveProcessors - Introducted in Windows 2000. */
+PFNKEQUERYACTIVEPROCESSORS              g_pfnrtKeQueryActiveProcessors;
+/** KeQueryMaximumProcessorCount   - Introducted in Vista and obsoleted W7. */
+PFNKEQUERYMAXIMUMPROCESSORCOUNT         g_pfnrtKeQueryMaximumProcessorCount;
+/** KeQueryMaximumProcessorCountEx - Introducted in Windows 7. */
+PFNKEQUERYMAXIMUMPROCESSORCOUNTEX       g_pfnrtKeQueryMaximumProcessorCountEx;
+/** KeQueryMaximumGroupCount - Introducted in Windows 7. */
+PFNKEQUERYMAXIMUMGROUPCOUNT             g_pfnrtKeQueryMaximumGroupCount;
+/** KeQueryActiveProcessorCount   - Introducted in Vista and obsoleted W7. */
+PFNKEQUERYACTIVEPROCESSORCOUNT          g_pfnrtKeQueryActiveProcessorCount;
+/** KeQueryActiveProcessorCountEx - Introducted in Windows 7. */
+PFNKEQUERYACTIVEPROCESSORCOUNTEX        g_pfnrtKeQueryActiveProcessorCountEx;
+/** KeQueryLogicalProcessorRelationship - Introducted in Windows 7. */
+PFNKEQUERYLOGICALPROCESSORRELATIONSHIP  g_pfnrtKeQueryLogicalProcessorRelationship;
+/** KeRegisterProcessorChangeCallback - Introducted in Windows 7. */
+PFNKEREGISTERPROCESSORCHANGECALLBACK    g_pfnrtKeRegisterProcessorChangeCallback;
+/** KeDeregisterProcessorChangeCallback - Introducted in Windows 7. */
+PFNKEDEREGISTERPROCESSORCHANGECALLBACK  g_pfnrtKeDeregisterProcessorChangeCallback;
 /** RtlGetVersion, introduced in ??. */
-PFNRTRTLGETVERSION                  g_pfnrtRtlGetVersion;
+PFNRTRTLGETVERSION                      g_pfnrtRtlGetVersion;
 #ifndef RT_ARCH_AMD64
 /** KeQueryInterruptTime - exported/new in Windows 2000. */
-PFNRTKEQUERYINTERRUPTTIME           g_pfnrtKeQueryInterruptTime;
+PFNRTKEQUERYINTERRUPTTIME               g_pfnrtKeQueryInterruptTime;
 /** KeQuerySystemTime - exported/new in Windows 2000. */
-PFNRTKEQUERYSYSTEMTIME              g_pfnrtKeQuerySystemTime;
+PFNRTKEQUERYSYSTEMTIME                  g_pfnrtKeQuerySystemTime;
 #endif
 /** KeQueryInterruptTimePrecise - new in Windows 8. */
-PFNRTKEQUERYINTERRUPTTIMEPRECISE    g_pfnrtKeQueryInterruptTimePrecise;
+PFNRTKEQUERYINTERRUPTTIMEPRECISE        g_pfnrtKeQueryInterruptTimePrecise;
 /** KeQuerySystemTimePrecise - new in Windows 8. */
-PFNRTKEQUERYSYSTEMTIMEPRECISE       g_pfnrtKeQuerySystemTimePrecise;
+PFNRTKEQUERYSYSTEMTIMEPRECISE           g_pfnrtKeQuerySystemTimePrecise;
 
 /** Offset of the _KPRCB::QuantumEnd field. 0 if not found. */
-uint32_t                            g_offrtNtPbQuantumEnd;
+uint32_t                                g_offrtNtPbQuantumEnd;
 /** Size of the _KPRCB::QuantumEnd field. 0 if not found. */
-uint32_t                            g_cbrtNtPbQuantumEnd;
+uint32_t                                g_cbrtNtPbQuantumEnd;
 /** Offset of the _KPRCB::DpcQueueDepth field. 0 if not found. */
-uint32_t                            g_offrtNtPbDpcQueueDepth;
+uint32_t                                g_offrtNtPbDpcQueueDepth;
 
 
 /**
@@ -124,9 +137,23 @@ static void rtR0NtGetOsVersionInfo(PRTNTSDBOSVER pOsVerInfo)
     }
 
     /* Note! We cannot quite say if something is MP or UNI. So, fSmp is
-             redefined to indicate that it must be MP. */
-    pOsVerInfo->fSmp        = RTMpGetCount() >  1
-                           || ulMajorVersion >= 6; /* Vista and later has no UNI kernel AFAIK. */
+             redefined to indicate that it must be MP.
+       Note! RTMpGetCount is not available here. */
+    pOsVerInfo->fSmp = ulMajorVersion >= 6; /* Vista and later has no UNI kernel AFAIK. */
+    if (!pOsVerInfo->fSmp)
+    {
+        if (   g_pfnrtKeQueryMaximumProcessorCountEx
+            && g_pfnrtKeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS) > 1)
+            pOsVerInfo->fSmp = true;
+        else if (   g_pfnrtKeQueryMaximumProcessorCount
+                 && g_pfnrtKeQueryMaximumProcessorCount() > 1)
+            pOsVerInfo->fSmp = true;
+        else if (   g_pfnrtKeQueryActiveProcessors
+                 && g_pfnrtKeQueryActiveProcessors() > 1)
+            pOsVerInfo->fSmp = true;
+        else if (KeNumberProcessors > 1)
+            pOsVerInfo->fSmp = true;
+    }
 }
 
 
@@ -205,72 +232,56 @@ static bool rtR0NtTryMatchSymSet(PCRTNTSDBSET pSet, uint8_t *pbPrcb, const char
 DECLHIDDEN(int) rtR0InitNative(void)
 {
     /*
-     * Init the Nt cpu set.
+     * Initialize the function pointers.
      */
 #ifdef IPRT_TARGET_NT4
-    KAFFINITY ActiveProcessors = (UINT64_C(1) << KeNumberProcessors) - UINT64_C(1);
+# define GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, a_pfnType) do { RT_CONCAT3(g_pfnrt, a_Prf, a_Name) = NULL; } while (0)
 #else
-    KAFFINITY ActiveProcessors = KeQueryActiveProcessors();
+    UNICODE_STRING RoutineName;
+# define GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, a_pfnType) \
+    do { \
+        RtlInitUnicodeString(&RoutineName, L#a_Name); \
+        RT_CONCAT3(g_pfnrt, a_Prf, a_Name) = (a_pfnType)MmGetSystemRoutineAddress(&RoutineName); \
+    } while (0)
+#endif
+#define GET_SYSTEM_ROUTINE(a_Name)                 GET_SYSTEM_ROUTINE_EX(RT_NOTHING, a_Name, decltype(a_Name) *)
+#define GET_SYSTEM_ROUTINE_PRF(a_Prf,a_Name)       GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, decltype(a_Name) *)
+#define GET_SYSTEM_ROUTINE_TYPE(a_Name, a_pfnType) GET_SYSTEM_ROUTINE_EX(RT_NOTHING, a_Name, a_pfnType)
+
+    GET_SYSTEM_ROUTINE_PRF(Nt,ExSetTimerResolution);
+    GET_SYSTEM_ROUTINE_PRF(Nt,KeFlushQueuedDpcs);
+    GET_SYSTEM_ROUTINE(KeIpiGenericCall);
+    GET_SYSTEM_ROUTINE(KeSetTargetProcessorDpcEx);
+    GET_SYSTEM_ROUTINE(KeInitializeAffinityEx);
+    GET_SYSTEM_ROUTINE(KeAddProcessorAffinityEx);
+    GET_SYSTEM_ROUTINE_TYPE(KeGetProcessorIndexFromNumber, PFNKEGETPROCESSORINDEXFROMNUMBER);
+    GET_SYSTEM_ROUTINE(KeGetProcessorNumberFromIndex);
+    GET_SYSTEM_ROUTINE_TYPE(KeGetCurrentProcessorNumberEx, PFNKEGETCURRENTPROCESSORNUMBEREX);
+    GET_SYSTEM_ROUTINE(KeQueryActiveProcessors);
+    GET_SYSTEM_ROUTINE(KeQueryMaximumProcessorCount);
+    GET_SYSTEM_ROUTINE(KeQueryMaximumProcessorCountEx);
+    GET_SYSTEM_ROUTINE(KeQueryMaximumGroupCount);
+    GET_SYSTEM_ROUTINE(KeQueryActiveProcessorCount);
+    GET_SYSTEM_ROUTINE(KeQueryActiveProcessorCountEx);
+    GET_SYSTEM_ROUTINE(KeQueryLogicalProcessorRelationship);
+    GET_SYSTEM_ROUTINE(KeRegisterProcessorChangeCallback);
+    GET_SYSTEM_ROUTINE(KeDeregisterProcessorChangeCallback);
+
+    GET_SYSTEM_ROUTINE_TYPE(RtlGetVersion, PFNRTRTLGETVERSION);
+#ifndef RT_ARCH_AMD64
+    GET_SYSTEM_ROUTINE(KeQueryInterruptTime);
+    GET_SYSTEM_ROUTINE(KeQuerySystemTime);
 #endif
-    RTCpuSetEmpty(&g_rtMpNtCpuSet);
-    RTCpuSetFromU64(&g_rtMpNtCpuSet, ActiveProcessors);
-/** @todo Port to W2K8 with > 64 cpus/threads. */
+    GET_SYSTEM_ROUTINE_TYPE(KeQueryInterruptTimePrecise, PFNRTKEQUERYINTERRUPTTIMEPRECISE);
+    GET_SYSTEM_ROUTINE_TYPE(KeQuerySystemTimePrecise, PFNRTKEQUERYSYSTEMTIMEPRECISE);
 
-    /*
-     * Initialize the function pointers.
-     */
 #ifdef IPRT_TARGET_NT4
-    g_pfnrtNtExSetTimerResolution = NULL;
-    g_pfnrtNtKeFlushQueuedDpcs = NULL;
     g_pfnrtHalRequestIpiW7Plus = NULL;
     g_pfnrtHalRequestIpiPreW7 = NULL;
-    g_pfnrtKeIpiGenericCall = NULL;
-    g_pfnrtKeInitializeAffinityEx = NULL;
-    g_pfnrtKeAddProcessorAffinityEx = NULL;
-    g_pfnrtKeGetProcessorIndexFromNumber = NULL;
-    g_pfnrtRtlGetVersion = NULL;
-    g_pfnrtKeQueryInterruptTime = NULL;
-    g_pfnrtKeQueryInterruptTimePrecise = NULL;
-    g_pfnrtKeQuerySystemTime = NULL;
-    g_pfnrtKeQuerySystemTimePrecise = NULL;
 #else
-    UNICODE_STRING RoutineName;
-    RtlInitUnicodeString(&RoutineName, L"ExSetTimerResolution");
-    g_pfnrtNtExSetTimerResolution = (PFNMYEXSETTIMERRESOLUTION)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"KeFlushQueuedDpcs");
-    g_pfnrtNtKeFlushQueuedDpcs = (PFNMYKEFLUSHQUEUEDDPCS)MmGetSystemRoutineAddress(&RoutineName);
-
     RtlInitUnicodeString(&RoutineName, L"HalRequestIpi");
     g_pfnrtHalRequestIpiW7Plus = (PFNHALREQUESTIPI_W7PLUS)MmGetSystemRoutineAddress(&RoutineName);
     g_pfnrtHalRequestIpiPreW7 = (PFNHALREQUESTIPI_PRE_W7)g_pfnrtHalRequestIpiW7Plus;
-
-    RtlInitUnicodeString(&RoutineName, L"KeIpiGenericCall");
-    g_pfnrtKeIpiGenericCall = (PFNRTKEIPIGENERICCALL)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"KeInitializeAffinityEx");
-    g_pfnrtKeInitializeAffinityEx = (PFNKEINITIALIZEAFFINITYEX)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"KeAddProcessorAffinityEx");
-    g_pfnrtKeAddProcessorAffinityEx = (PFNKEADDPROCESSORAFFINITYEX)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"KeGetProcessorIndexFromNumber");
-    g_pfnrtKeGetProcessorIndexFromNumber = (PFNKEGETPROCESSORINDEXFROMNUMBER)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"RtlGetVersion");
-    g_pfnrtRtlGetVersion = (PFNRTRTLGETVERSION)MmGetSystemRoutineAddress(&RoutineName);
-# ifndef RT_ARCH_AMD64
-    RtlInitUnicodeString(&RoutineName, L"KeQueryInterruptTime");
-    g_pfnrtKeQueryInterruptTime = (PFNRTKEQUERYINTERRUPTTIME)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"KeQuerySystemTime");
-    g_pfnrtKeQuerySystemTime = (PFNRTKEQUERYSYSTEMTIME)MmGetSystemRoutineAddress(&RoutineName);
-# endif
-    RtlInitUnicodeString(&RoutineName, L"KeQueryInterruptTimePrecise");
-    g_pfnrtKeQueryInterruptTimePrecise = (PFNRTKEQUERYINTERRUPTTIMEPRECISE)MmGetSystemRoutineAddress(&RoutineName);
-
-    RtlInitUnicodeString(&RoutineName, L"KeQuerySystemTimePrecise");
-    g_pfnrtKeQuerySystemTimePrecise = (PFNRTKEQUERYSYSTEMTIMEPRECISE)MmGetSystemRoutineAddress(&RoutineName);
 #endif
 
     /*
@@ -396,53 +407,22 @@ DECLHIDDEN(int) rtR0InitNative(void)
 # ifdef DEBUG
     else
         DbgPrint("IPRT: _KPRCB:{.QuantumEnd=%x/%d, .DpcQueueDepth=%x/%d} Kernel %u.%u %u %s\n",
-                 g_offrtNtPbQuantumEnd, g_cbrtNtPbQuantumEnd, g_offrtNtPbDpcQueueDepth,
+                 g_offrtNtPbQuantumEnd, g_cbrtNtPbQuantumEnd, g_offrtNtPbDpcQueueDepth, g_offrtNtPbDpcQueueDepth,
                  OsVerInfo.uMajorVer, OsVerInfo.uMinorVer, OsVerInfo.uBuildNo, OsVerInfo.fChecked ? "checked" : "free");
 # endif
 #endif
 
     /*
-     * Special IPI fun for RTMpPokeCpu.
-     *
-     * On Vista and later the DPC method doesn't seem to reliably send IPIs,
-     * so we have to use alternative methods.
-     *
-     * On AMD64 We used to use the HalSendSoftwareInterrupt API (also x86 on
-     * W10+), it looks faster and more convenient to use, however we're either
-     * using it wrong or it doesn't reliably do what we want (see @bugref{8343}).
-     *
-     * The HalRequestIpip API is thus far the only alternative to KeInsertQueueDpc
-     * for doing targetted IPIs.  Trouble with this API is that it changed
-     * fundamentally in Window 7 when they added support for lots of processors.
-     *
-     * If we really think we cannot use KeInsertQueueDpc, we use the broadcast IPI
-     * API KeIpiGenericCall.
+     * Initialize multi processor stuff.  This registers a callback, so
+     * we call rtR0TermNative to do the deregistration on failure.
      */
-    if (   OsVerInfo.uMajorVer > 6
-        || (OsVerInfo.uMajorVer == 6 && OsVerInfo.uMinorVer > 0))
-        g_pfnrtHalRequestIpiPreW7 = NULL;
-    else
-        g_pfnrtHalRequestIpiW7Plus = NULL;
-
-    g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingDpc;
-#ifndef IPRT_TARGET_NT4
-    if (   g_pfnrtHalRequestIpiW7Plus
-        && g_pfnrtKeInitializeAffinityEx
-        && g_pfnrtKeAddProcessorAffinityEx
-        && g_pfnrtKeGetProcessorIndexFromNumber)
+    int rc = rtR0MpNtInit(&OsVerInfo);
+    if (RT_FAILURE(rc))
     {
-        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingHalReqestIpiW7Plus\n");
-        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingHalReqestIpiW7Plus;
+        rtR0TermNative();
+        DbgPrint("IPRT: Fatal: rtR0MpNtInit failed: %d\n", rc);
+        return rc;
     }
-    else if (OsVerInfo.uMajorVer >= 6 && g_pfnrtKeIpiGenericCall)
-    {
-        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingBroadcastIpi\n");
-        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingBroadcastIpi;
-    }
-    else
-        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingDpc\n");
-    /* else: Windows XP should send always send an IPI -> VERIFY */
-#endif
 
     return VINF_SUCCESS;
 }
@@ -450,5 +430,6 @@ DECLHIDDEN(int) rtR0InitNative(void)
 
 DECLHIDDEN(void) rtR0TermNative(void)
 {
+    rtR0MpNtTerm();
 }
 
diff --git a/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h b/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h
index a81e47e..9e058cd 100644
--- a/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h
+++ b/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h
@@ -52,28 +52,44 @@ typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIMEPRECISE)(PLARGE_INTEGER pTime);
 /*******************************************************************************
 *   Global Variables                                                           *
 *******************************************************************************/
-extern RTCPUSET                         g_rtMpNtCpuSet;
-extern PFNMYEXSETTIMERRESOLUTION        g_pfnrtNtExSetTimerResolution;
-extern PFNMYKEFLUSHQUEUEDDPCS           g_pfnrtNtKeFlushQueuedDpcs;
-extern PFNHALREQUESTIPI_W7PLUS          g_pfnrtHalRequestIpiW7Plus;
-extern PFNHALREQUESTIPI_PRE_W7          g_pfnrtHalRequestIpiPreW7;
-extern PFNHALSENDSOFTWAREINTERRUPT      g_pfnrtNtHalSendSoftwareInterrupt;
-extern PFNRTSENDIPI                     g_pfnrtMpPokeCpuWorker;
-extern PFNRTKEIPIGENERICCALL            g_pfnrtKeIpiGenericCall;
-extern PFNKEINITIALIZEAFFINITYEX        g_pfnrtKeInitializeAffinityEx;
-extern PFNKEADDPROCESSORAFFINITYEX      g_pfnrtKeAddProcessorAffinityEx;
-extern PFNKEGETPROCESSORINDEXFROMNUMBER g_pfnrtKeGetProcessorIndexFromNumber;
+extern RTCPUSET                                g_rtMpNtCpuSet;
+extern uint32_t                                g_cRtMpNtMaxGroups;
+extern uint32_t                                g_cRtMpNtMaxCpus;
+extern RTCPUID                                 g_aidRtMpNtByCpuSetIdx[RTCPUSET_MAX_CPUS];
 
-extern PFNRTRTLGETVERSION               g_pfnrtRtlGetVersion;
+extern PFNMYEXSETTIMERRESOLUTION               g_pfnrtNtExSetTimerResolution;
+extern PFNMYKEFLUSHQUEUEDDPCS                  g_pfnrtNtKeFlushQueuedDpcs;
+extern PFNHALREQUESTIPI_W7PLUS                 g_pfnrtHalRequestIpiW7Plus;
+extern PFNHALREQUESTIPI_PRE_W7                 g_pfnrtHalRequestIpiPreW7;
+extern PFNHALSENDSOFTWAREINTERRUPT             g_pfnrtNtHalSendSoftwareInterrupt;
+extern PFNRTSENDIPI                            g_pfnrtMpPokeCpuWorker;
+extern PFNRTKEIPIGENERICCALL                   g_pfnrtKeIpiGenericCall;
+extern PFNKESETTARGETPROCESSORDPCEX            g_pfnrtKeSetTargetProcessorDpcEx;
+extern PFNKEINITIALIZEAFFINITYEX               g_pfnrtKeInitializeAffinityEx;
+extern PFNKEADDPROCESSORAFFINITYEX             g_pfnrtKeAddProcessorAffinityEx;
+extern PFNKEGETPROCESSORINDEXFROMNUMBER        g_pfnrtKeGetProcessorIndexFromNumber;
+extern PFNKEGETPROCESSORNUMBERFROMINDEX        g_pfnrtKeGetProcessorNumberFromIndex;
+extern PFNKEGETCURRENTPROCESSORNUMBEREX        g_pfnrtKeGetCurrentProcessorNumberEx;
+extern PFNKEQUERYACTIVEPROCESSORS              g_pfnrtKeQueryActiveProcessors;
+extern PFNKEQUERYMAXIMUMPROCESSORCOUNT         g_pfnrtKeQueryMaximumProcessorCount;
+extern PFNKEQUERYMAXIMUMPROCESSORCOUNTEX       g_pfnrtKeQueryMaximumProcessorCountEx;
+extern PFNKEQUERYMAXIMUMGROUPCOUNT             g_pfnrtKeQueryMaximumGroupCount;
+extern PFNKEQUERYACTIVEPROCESSORCOUNT          g_pfnrtKeQueryActiveProcessorCount;
+extern PFNKEQUERYACTIVEPROCESSORCOUNTEX        g_pfnrtKeQueryActiveProcessorCountEx;
+extern PFNKEQUERYLOGICALPROCESSORRELATIONSHIP  g_pfnrtKeQueryLogicalProcessorRelationship;
+extern PFNKEREGISTERPROCESSORCHANGECALLBACK    g_pfnrtKeRegisterProcessorChangeCallback;
+extern PFNKEDEREGISTERPROCESSORCHANGECALLBACK  g_pfnrtKeDeregisterProcessorChangeCallback;
+extern PFNRTRTLGETVERSION                      g_pfnrtRtlGetVersion;
 #ifndef RT_ARCH_AMD64
-extern PFNRTKEQUERYINTERRUPTTIME        g_pfnrtKeQueryInterruptTime;
-extern PFNRTKEQUERYSYSTEMTIME           g_pfnrtKeQuerySystemTime;
+extern PFNRTKEQUERYINTERRUPTTIME               g_pfnrtKeQueryInterruptTime;
+extern PFNRTKEQUERYSYSTEMTIME                  g_pfnrtKeQuerySystemTime;
 #endif
-extern PFNRTKEQUERYINTERRUPTTIMEPRECISE g_pfnrtKeQueryInterruptTimePrecise;
-extern PFNRTKEQUERYSYSTEMTIMEPRECISE    g_pfnrtKeQuerySystemTimePrecise;
-extern uint32_t                         g_offrtNtPbQuantumEnd;
-extern uint32_t                         g_cbrtNtPbQuantumEnd;
-extern uint32_t                         g_offrtNtPbDpcQueueDepth;
+extern PFNRTKEQUERYINTERRUPTTIMEPRECISE        g_pfnrtKeQueryInterruptTimePrecise;
+extern PFNRTKEQUERYSYSTEMTIMEPRECISE           g_pfnrtKeQuerySystemTimePrecise;
+
+extern uint32_t                                g_offrtNtPbQuantumEnd;
+extern uint32_t                                g_cbrtNtPbQuantumEnd;
+extern uint32_t                                g_offrtNtPbDpcQueueDepth;
 
 
 int __stdcall rtMpPokeCpuUsingDpc(RTCPUID idCpu);
@@ -81,6 +97,11 @@ int __stdcall rtMpPokeCpuUsingBroadcastIpi(RTCPUID idCpu);
 int __stdcall rtMpPokeCpuUsingHalReqestIpiW7Plus(RTCPUID idCpu);
 int __stdcall rtMpPokeCpuUsingHalReqestIpiPreW7(RTCPUID idCpu);
 
+struct RTNTSDBOSVER;
+DECLHIDDEN(int)  rtR0MpNtInit(struct RTNTSDBOSVER const *pOsVerInfo);
+DECLHIDDEN(void) rtR0MpNtTerm(void);
+DECLHIDDEN(int) rtMpNtSetTargetProcessorDpc(KDPC *pDpc, RTCPUID idCpu);
+
 RT_C_DECLS_END
 
 #endif
diff --git a/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp b/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp
index 9b02878..5824644 100644
--- a/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp
+++ b/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp
@@ -35,9 +35,12 @@
 #include <iprt/err.h>
 #include <iprt/asm.h>
 #include <iprt/log.h>
+#include <iprt/mem.h>
 #include <iprt/time.h>
 #include "r0drv/mp-r0drv.h"
+#include "symdb.h"
 #include "internal-r0drv-nt.h"
+#include "internal/mp.h"
 
 
 /*********************************************************************************************************************************
@@ -74,107 +77,1052 @@ typedef struct RTMPNTONSPECIFICARGS
 typedef RTMPNTONSPECIFICARGS *PRTMPNTONSPECIFICARGS;
 
 
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+/** Inactive bit for g_aidRtMpNtByCpuSetIdx. */
+#define RTMPNT_ID_F_INACTIVE    RT_BIT_32(31)
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+/** Maximum number of processor groups. */
+uint32_t                                g_cRtMpNtMaxGroups;
+/** Maximum number of processors. */
+uint32_t                                g_cRtMpNtMaxCpus;
+/** Number of active processors. */
+uint32_t volatile                       g_cRtMpNtActiveCpus;
+/** The NT CPU set.
+ * KeQueryActiveProcssors() cannot be called at all IRQLs and therefore we'll
+ * have to cache it.  Fortunately, NT doesn't really support taking CPUs offline,
+ * and taking them online was introduced with W2K8 where it is intended for virtual
+ * machines and not real HW.  We update this, g_cRtMpNtActiveCpus and
+ * g_aidRtMpNtByCpuSetIdx from the rtR0NtMpProcessorChangeCallback.
+ */
+RTCPUSET                                g_rtMpNtCpuSet;
+
+/** Static per group info.
+ * @remarks  With RTCPUSET_MAX_CPUS as 256, this takes up 33KB. */
+static struct
+{
+    /** The max CPUs in the group. */
+    uint16_t    cMaxCpus;
+    /** The number of active CPUs at the time of initialization. */
+    uint16_t    cActiveCpus;
+    /** CPU set indexes for each CPU in the group. */
+    int16_t     aidxCpuSetMembers[64];
+}                                       g_aRtMpNtCpuGroups[RTCPUSET_MAX_CPUS];
+/** Maps CPU set indexes to RTCPUID.
+ * Inactive CPUs has bit 31 set (RTMPNT_ID_F_INACTIVE) so we can identify them
+ * and shuffle duplicates during CPU hotplugging.  We assign temporary IDs to
+ * the inactive CPUs starting at g_cRtMpNtMaxCpus - 1, ASSUMING that active
+ * CPUs has IDs from 0 to g_cRtMpNtActiveCpus. */
+RTCPUID                                 g_aidRtMpNtByCpuSetIdx[RTCPUSET_MAX_CPUS];
+/** The handle of the rtR0NtMpProcessorChangeCallback registration. */
+static PVOID                            g_pvMpCpuChangeCallback = NULL;
+
+
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
+static VOID __stdcall rtR0NtMpProcessorChangeCallback(void *pvUser, PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT pChangeCtx,
+                                                      PNTSTATUS prcOperationStatus);
+static int rtR0NtInitQueryGroupRelations(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **ppInfo);
+
+
+
+/**
+ * Initalizes multiprocessor globals (called by rtR0InitNative).
+ *
+ * @returns IPRT status code.
+ * @param   pOsVerInfo          Version information.
+ */
+DECLHIDDEN(int) rtR0MpNtInit(RTNTSDBOSVER const *pOsVerInfo)
+{
+#define MY_CHECK_BREAK(a_Check, a_DbgPrintArgs) \
+        AssertMsgBreakStmt(a_Check, a_DbgPrintArgs, DbgPrint a_DbgPrintArgs; rc = VERR_INTERNAL_ERROR_4 )
+#define MY_CHECK_RETURN(a_Check, a_DbgPrintArgs, a_rcRet) \
+        AssertMsgReturnStmt(a_Check, a_DbgPrintArgs, DbgPrint a_DbgPrintArgs, a_rcRet)
+#define MY_CHECK(a_Check, a_DbgPrintArgs) \
+        AssertMsgStmt(a_Check, a_DbgPrintArgs, DbgPrint a_DbgPrintArgs; rc = VERR_INTERNAL_ERROR_4 )
+
+    /*
+     * API combination checks.
+     */
+    MY_CHECK_RETURN(!g_pfnrtKeSetTargetProcessorDpcEx || g_pfnrtKeGetProcessorNumberFromIndex,
+                    ("IPRT: Fatal: Missing KeSetTargetProcessorDpcEx without KeGetProcessorNumberFromIndex!\n"),
+                    VERR_SYMBOL_NOT_FOUND);
+
+    /*
+     * Get max number of processor groups.
+     *
+     * We may need to upadjust this number below, because windows likes to keep
+     * all options open when it comes to hotplugged CPU group assignments.  A
+     * server advertising up to 64 CPUs in the ACPI table will get a result of
+     * 64 from KeQueryMaximumGroupCount.  That makes sense.  However, when windows
+     * server 2012 does a two processor group setup for it, the sum of the
+     * GroupInfo[*].MaximumProcessorCount members below is 128.  This is probably
+     * because windows doesn't want to make decisions grouping of hotpluggable CPUs.
+     * So, we need to bump the maximum count to 128 below do deal with this as we
+     * want to have valid CPU set indexes for all potential CPUs - how could we
+     * otherwise use the RTMpGetSet() result and also RTCpuSetCount(RTMpGetSet())
+     * should equal RTMpGetCount().
+     */
+    if (g_pfnrtKeQueryMaximumGroupCount)
+    {
+        g_cRtMpNtMaxGroups = g_pfnrtKeQueryMaximumGroupCount();
+        MY_CHECK_RETURN(g_cRtMpNtMaxGroups <= RTCPUSET_MAX_CPUS && g_cRtMpNtMaxGroups > 0,
+                        ("IPRT: Fatal: g_cRtMpNtMaxGroups=%u, max %u\n", g_cRtMpNtMaxGroups, RTCPUSET_MAX_CPUS),
+                        VERR_MP_TOO_MANY_CPUS);
+    }
+    else
+        g_cRtMpNtMaxGroups = 1;
+
+    /*
+     * Get max number CPUs.
+     * This also defines the range of NT CPU indexes, RTCPUID and index into RTCPUSET.
+     */
+    if (g_pfnrtKeQueryMaximumProcessorCountEx)
+    {
+        g_cRtMpNtMaxCpus = g_pfnrtKeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS);
+        MY_CHECK_RETURN(g_cRtMpNtMaxCpus <= RTCPUSET_MAX_CPUS && g_cRtMpNtMaxCpus > 0,
+                        ("IPRT: Fatal: g_cRtMpNtMaxCpus=%u, max %u [KeQueryMaximumProcessorCountEx]\n",
+                         g_cRtMpNtMaxGroups, RTCPUSET_MAX_CPUS),
+                        VERR_MP_TOO_MANY_CPUS);
+    }
+    else if (g_pfnrtKeQueryMaximumProcessorCount)
+    {
+        g_cRtMpNtMaxCpus = g_pfnrtKeQueryMaximumProcessorCount();
+        MY_CHECK_RETURN(g_cRtMpNtMaxCpus <= RTCPUSET_MAX_CPUS && g_cRtMpNtMaxCpus > 0,
+                        ("IPRT: Fatal: g_cRtMpNtMaxCpus=%u, max %u [KeQueryMaximumProcessorCount]\n",
+                         g_cRtMpNtMaxGroups, RTCPUSET_MAX_CPUS),
+                        VERR_MP_TOO_MANY_CPUS);
+    }
+    else if (g_pfnrtKeQueryActiveProcessors)
+    {
+        KAFFINITY fActiveProcessors = g_pfnrtKeQueryActiveProcessors();
+        MY_CHECK_RETURN(fActiveProcessors != 0,
+                        ("IPRT: Fatal: KeQueryActiveProcessors returned 0!\n"),
+                        VERR_INTERNAL_ERROR_2);
+        g_cRtMpNtMaxCpus = 0;
+        do
+        {
+            g_cRtMpNtMaxCpus++;
+            fActiveProcessors >>= 1;
+        } while (fActiveProcessors);
+    }
+    else
+        g_cRtMpNtMaxCpus = KeNumberProcessors;
+
+    /*
+     * Just because we're a bit paranoid about getting something wrong wrt to the
+     * kernel interfaces, we try 16 times to get the KeQueryActiveProcessorCountEx
+     * and KeQueryLogicalProcessorRelationship information to match up.
+     */
+    for (unsigned cTries = 0;; cTries++)
+    {
+        /*
+         * Get number of active CPUs.
+         */
+        if (g_pfnrtKeQueryActiveProcessorCountEx)
+        {
+            g_cRtMpNtActiveCpus = g_pfnrtKeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
+            MY_CHECK_RETURN(g_cRtMpNtActiveCpus <= g_cRtMpNtMaxCpus && g_cRtMpNtActiveCpus > 0,
+                            ("IPRT: Fatal: g_cRtMpNtMaxGroups=%u, max %u [KeQueryActiveProcessorCountEx]\n",
+                             g_cRtMpNtMaxGroups, g_cRtMpNtMaxCpus),
+                            VERR_MP_TOO_MANY_CPUS);
+        }
+        else if (g_pfnrtKeQueryActiveProcessorCount)
+        {
+            g_cRtMpNtActiveCpus = g_pfnrtKeQueryActiveProcessorCount(NULL);
+            MY_CHECK_RETURN(g_cRtMpNtActiveCpus <= g_cRtMpNtMaxCpus && g_cRtMpNtActiveCpus > 0,
+                            ("IPRT: Fatal: g_cRtMpNtMaxGroups=%u, max %u [KeQueryActiveProcessorCount]\n",
+                             g_cRtMpNtMaxGroups, g_cRtMpNtMaxCpus),
+                            VERR_MP_TOO_MANY_CPUS);
+        }
+        else
+            g_cRtMpNtActiveCpus = g_cRtMpNtMaxCpus;
+
+        /*
+         * Query the details for the groups to figure out which CPUs are online as
+         * well as the NT index limit.
+         */
+        for (unsigned i = 0; i < RT_ELEMENTS(g_aidRtMpNtByCpuSetIdx); i++)
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+            g_aidRtMpNtByCpuSetIdx[i] = NIL_RTCPUID;
+#else
+            g_aidRtMpNtByCpuSetIdx[i] = i < g_cRtMpNtMaxCpus ? i : NIL_RTCPUID;
+#endif
+        for (unsigned idxGroup = 0; idxGroup < RT_ELEMENTS(g_aRtMpNtCpuGroups); idxGroup++)
+        {
+            g_aRtMpNtCpuGroups[idxGroup].cMaxCpus    = 0;
+            g_aRtMpNtCpuGroups[idxGroup].cActiveCpus = 0;
+            for (unsigned idxMember = 0; idxMember < RT_ELEMENTS(g_aRtMpNtCpuGroups[idxGroup].aidxCpuSetMembers); idxMember++)
+                g_aRtMpNtCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = -1;
+        }
+
+        if (g_pfnrtKeQueryLogicalProcessorRelationship)
+        {
+            MY_CHECK_RETURN(g_pfnrtKeGetProcessorIndexFromNumber,
+                            ("IPRT: Fatal: Found KeQueryLogicalProcessorRelationship but not KeGetProcessorIndexFromNumber!\n"),
+                            VERR_SYMBOL_NOT_FOUND);
+            MY_CHECK_RETURN(g_pfnrtKeGetProcessorNumberFromIndex,
+                            ("IPRT: Fatal: Found KeQueryLogicalProcessorRelationship but not KeGetProcessorIndexFromNumber!\n"),
+                            VERR_SYMBOL_NOT_FOUND);
+            MY_CHECK_RETURN(g_pfnrtKeSetTargetProcessorDpcEx,
+                            ("IPRT: Fatal: Found KeQueryLogicalProcessorRelationship but not KeSetTargetProcessorDpcEx!\n"),
+                            VERR_SYMBOL_NOT_FOUND);
+
+            SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pInfo = NULL;
+            int rc = rtR0NtInitQueryGroupRelations(&pInfo);
+            if (RT_FAILURE(rc))
+                return rc;
+
+            MY_CHECK(pInfo->Group.MaximumGroupCount == g_cRtMpNtMaxGroups,
+                     ("IPRT: Fatal: MaximumGroupCount=%u != g_cRtMpNtMaxGroups=%u!\n",
+                      pInfo->Group.MaximumGroupCount, g_cRtMpNtMaxGroups));
+            MY_CHECK(pInfo->Group.ActiveGroupCount > 0 && pInfo->Group.ActiveGroupCount <= g_cRtMpNtMaxGroups,
+                     ("IPRT: Fatal: ActiveGroupCount=%u != g_cRtMpNtMaxGroups=%u!\n",
+                      pInfo->Group.ActiveGroupCount, g_cRtMpNtMaxGroups));
+
+            /*
+             * First we need to recalc g_cRtMpNtMaxCpus (see above).
+             */
+            uint32_t cMaxCpus = 0;
+            uint32_t idxGroup;
+            for (idxGroup = 0; RT_SUCCESS(rc) && idxGroup < pInfo->Group.ActiveGroupCount; idxGroup++)
+            {
+                const PROCESSOR_GROUP_INFO *pGrpInfo = &pInfo->Group.GroupInfo[idxGroup];
+                MY_CHECK_BREAK(pGrpInfo->MaximumProcessorCount <= MAXIMUM_PROC_PER_GROUP,
+                               ("IPRT: Fatal: MaximumProcessorCount=%u\n", pGrpInfo->MaximumProcessorCount));
+                MY_CHECK_BREAK(pGrpInfo->ActiveProcessorCount <= pGrpInfo->MaximumProcessorCount,
+                               ("IPRT: Fatal: ActiveProcessorCount=%u > MaximumProcessorCount=%u\n",
+                                pGrpInfo->ActiveProcessorCount, pGrpInfo->MaximumProcessorCount));
+                cMaxCpus += pGrpInfo->MaximumProcessorCount;
+            }
+            if (cMaxCpus > g_cRtMpNtMaxCpus && RT_SUCCESS(rc))
+            {
+                DbgPrint("IPRT: g_cRtMpNtMaxCpus=%u -> %u\n", g_cRtMpNtMaxCpus, cMaxCpus);
+#ifndef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                uint32_t i = RT_MIN(cMaxCpus, RT_ELEMENTS(g_aidRtMpNtByCpuSetIdx));
+                while (i-- > g_cRtMpNtMaxCpus)
+                    g_aidRtMpNtByCpuSetIdx[i] = i;
+#endif
+                g_cRtMpNtMaxCpus = cMaxCpus;
+                if (g_cRtMpNtMaxGroups > RTCPUSET_MAX_CPUS)
+                {
+                    MY_CHECK(g_cRtMpNtMaxGroups <= RTCPUSET_MAX_CPUS && g_cRtMpNtMaxGroups > 0,
+                             ("IPRT: Fatal: g_cRtMpNtMaxGroups=%u, max %u\n", g_cRtMpNtMaxGroups, RTCPUSET_MAX_CPUS));
+                    rc = VERR_MP_TOO_MANY_CPUS;
+                }
+            }
+
+            /*
+             * Calc online mask, partition IDs and such.
+             *
+             * Also check ASSUMPTIONS:
+             *
+             *      1. Processor indexes going from 0 and up to
+             *         KeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS) - 1.
+             *
+             *      2. Currently valid processor indexes, i.e. accepted by
+             *         KeGetProcessorIndexFromNumber & KeGetProcessorNumberFromIndex, goes
+             *         from 0 thru KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS) - 1.
+             *
+             *      3. PROCESSOR_GROUP_INFO::MaximumProcessorCount gives the number of
+             *         relevant bits in the ActiveProcessorMask (from LSB).
+             *
+             *      4. Active processor count found in KeQueryLogicalProcessorRelationship
+             *         output matches what KeQueryActiveProcessorCountEx(ALL) returns.
+             *
+             *      5. Active + inactive processor counts in same does not exceed
+             *         KeQueryMaximumProcessorCountEx(ALL).
+             *
+             * Note! Processor indexes are assigned as CPUs come online and are not
+             *       preallocated according to group maximums.  Since CPUS are only taken
+             *       online and never offlined, this means that internal CPU bitmaps are
+             *       never sparse and no time is wasted scanning unused bits.
+             *
+             *       Unfortunately, it means that ring-3 cannot easily guess the index
+             *       assignments when hotswapping is used, and must use GIP when available.
+             */
+            RTCpuSetEmpty(&g_rtMpNtCpuSet);
+            uint32_t cInactive = 0;
+            uint32_t cActive   = 0;
+            uint32_t idxCpuMax = 0;
+            uint32_t idxCpuSetNextInactive = g_cRtMpNtMaxCpus - 1;
+            for (idxGroup = 0; RT_SUCCESS(rc) && idxGroup < pInfo->Group.ActiveGroupCount; idxGroup++)
+            {
+                const PROCESSOR_GROUP_INFO *pGrpInfo = &pInfo->Group.GroupInfo[idxGroup];
+                MY_CHECK_BREAK(pGrpInfo->MaximumProcessorCount <= MAXIMUM_PROC_PER_GROUP,
+                               ("IPRT: Fatal: MaximumProcessorCount=%u\n", pGrpInfo->MaximumProcessorCount));
+                MY_CHECK_BREAK(pGrpInfo->ActiveProcessorCount <= pGrpInfo->MaximumProcessorCount,
+                               ("IPRT: Fatal: ActiveProcessorCount=%u > MaximumProcessorCount=%u\n",
+                                pGrpInfo->ActiveProcessorCount, pGrpInfo->MaximumProcessorCount));
+
+                g_aRtMpNtCpuGroups[idxGroup].cMaxCpus    = pGrpInfo->MaximumProcessorCount;
+                g_aRtMpNtCpuGroups[idxGroup].cActiveCpus = pGrpInfo->ActiveProcessorCount;
+
+                for (uint32_t idxMember = 0; idxMember < pGrpInfo->MaximumProcessorCount; idxMember++)
+                {
+                    PROCESSOR_NUMBER ProcNum;
+                    ProcNum.Group    = (USHORT)idxGroup;
+                    ProcNum.Number   = (UCHAR)idxMember;
+                    ProcNum.Reserved = 0;
+                    ULONG idxCpu = g_pfnrtKeGetProcessorIndexFromNumber(&ProcNum);
+                    if (idxCpu != INVALID_PROCESSOR_INDEX)
+                    {
+                        MY_CHECK_BREAK(idxCpu < g_cRtMpNtMaxCpus && idxCpu < RTCPUSET_MAX_CPUS, /* ASSUMPTION #1 */
+                                       ("IPRT: Fatal: idxCpu=%u >= g_cRtMpNtMaxCpus=%u (RTCPUSET_MAX_CPUS=%u)\n",
+                                        idxCpu, g_cRtMpNtMaxCpus, RTCPUSET_MAX_CPUS));
+                        if (idxCpu > idxCpuMax)
+                            idxCpuMax = idxCpu;
+                        g_aRtMpNtCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxCpu;
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                        g_aidRtMpNtByCpuSetIdx[idxCpu] = RTMPCPUID_FROM_GROUP_AND_NUMBER(idxGroup, idxMember);
+#endif
+
+                        ProcNum.Group    = UINT16_MAX;
+                        ProcNum.Number   = UINT8_MAX;
+                        ProcNum.Reserved = UINT8_MAX;
+                        NTSTATUS rcNt = g_pfnrtKeGetProcessorNumberFromIndex(idxCpu, &ProcNum);
+                        MY_CHECK_BREAK(NT_SUCCESS(rcNt),
+                                       ("IPRT: Fatal: KeGetProcessorNumberFromIndex(%u,) -> %#x!\n", idxCpu, rcNt));
+                        MY_CHECK_BREAK(ProcNum.Group == idxGroup && ProcNum.Number == idxMember,
+                                       ("IPRT: Fatal: KeGetProcessorXxxxFromYyyy roundtrip error for %#x! Group: %u vs %u, Number: %u vs %u\n",
+                                        idxCpu, ProcNum.Group, idxGroup, ProcNum.Number, idxMember));
+
+                        if (pGrpInfo->ActiveProcessorMask & RT_BIT_64(idxMember))
+                        {
+                            RTCpuSetAddByIndex(&g_rtMpNtCpuSet, idxCpu);
+                            cActive++;
+                        }
+                        else
+                            cInactive++; /* (This is a little unexpected, but not important as long as things add up below.) */
+                    }
+                    else
+                    {
+                        /* Must be not present / inactive when KeGetProcessorIndexFromNumber fails. */
+                        MY_CHECK_BREAK(!(pGrpInfo->ActiveProcessorMask & RT_BIT_64(idxMember)),
+                                       ("IPRT: Fatal: KeGetProcessorIndexFromNumber(%u/%u) failed but CPU is active! cMax=%u cActive=%u fActive=%p\n",
+                                        idxGroup, idxMember, pGrpInfo->MaximumProcessorCount, pGrpInfo->ActiveProcessorCount,
+                                        pGrpInfo->ActiveProcessorMask));
+                        cInactive++;
+                        if (idxCpuSetNextInactive >= g_cRtMpNtActiveCpus)
+                        {
+                            g_aRtMpNtCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxCpuSetNextInactive;
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                            g_aidRtMpNtByCpuSetIdx[idxCpuSetNextInactive] = RTMPCPUID_FROM_GROUP_AND_NUMBER(idxGroup, idxMember)
+                                                                          | RTMPNT_ID_F_INACTIVE;
+#endif
+                            idxCpuSetNextInactive--;
+                        }
+                    }
+                }
+            }
+
+            MY_CHECK(cInactive + cActive <= g_cRtMpNtMaxCpus, /* ASSUMPTION #5 (not '==' because of inactive groups) */
+                     ("IPRT: Fatal: cInactive=%u + cActive=%u > g_cRtMpNtMaxCpus=%u\n", cInactive, cActive, g_cRtMpNtMaxCpus));
+
+            /* Deal with inactive groups using KeQueryMaximumProcessorCountEx or as
+               best as we can by as best we can by stipulating maximum member counts
+               from the previous group. */
+            if (   RT_SUCCESS(rc)
+                && idxGroup < pInfo->Group.MaximumGroupCount)
+            {
+                uint16_t cInactiveLeft = g_cRtMpNtMaxCpus - (cInactive + cActive);
+                while (idxGroup < pInfo->Group.MaximumGroupCount)
+                {
+                    uint32_t cMaxMembers = 0;
+                    if (g_pfnrtKeQueryMaximumProcessorCountEx)
+                        cMaxMembers = g_pfnrtKeQueryMaximumProcessorCountEx(idxGroup);
+                    if (cMaxMembers != 0 || cInactiveLeft == 0)
+                        AssertStmt(cMaxMembers <= cInactiveLeft, cMaxMembers = cInactiveLeft);
+                    else
+                    {
+                        uint16_t cGroupsLeft = pInfo->Group.MaximumGroupCount - idxGroup;
+                        cMaxMembers = pInfo->Group.GroupInfo[idxGroup - 1].MaximumProcessorCount;
+                        while (cMaxMembers * cGroupsLeft < cInactiveLeft)
+                            cMaxMembers++;
+                        if (cMaxMembers > cInactiveLeft)
+                            cMaxMembers = cInactiveLeft;
+                    }
+
+                    g_aRtMpNtCpuGroups[idxGroup].cMaxCpus    = (uint16_t)cMaxMembers;
+                    g_aRtMpNtCpuGroups[idxGroup].cActiveCpus = 0;
+                    for (uint16_t idxMember = 0; idxMember < cMaxMembers; idxMember++)
+                        if (idxCpuSetNextInactive >= g_cRtMpNtActiveCpus)
+                        {
+                            g_aRtMpNtCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxCpuSetNextInactive;
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                            g_aidRtMpNtByCpuSetIdx[idxCpuSetNextInactive] = RTMPCPUID_FROM_GROUP_AND_NUMBER(idxGroup, idxMember)
+                                                                          | RTMPNT_ID_F_INACTIVE;
+#endif
+                            idxCpuSetNextInactive--;
+                        }
+                    cInactiveLeft -= cMaxMembers;
+                    idxGroup++;
+                }
+            }
+
+            /* We're done with pInfo now, free it so we can start returning when assertions fail. */
+            RTMemFree(pInfo);
+            if (RT_FAILURE(rc)) /* MY_CHECK_BREAK sets rc. */
+                return rc;
+            MY_CHECK_RETURN(cActive >= g_cRtMpNtActiveCpus,
+                            ("IPRT: Fatal: cActive=%u < g_cRtMpNtActiveCpus=%u - CPUs removed?\n", cActive, g_cRtMpNtActiveCpus),
+                            VERR_INTERNAL_ERROR_3);
+            MY_CHECK_RETURN(idxCpuMax < cActive, /* ASSUMPTION #2 */
+                            ("IPRT: Fatal: idCpuMax=%u >= cActive=%u! Unexpected CPU index allocation. CPUs removed?\n",
+                             idxCpuMax, cActive),
+                            VERR_INTERNAL_ERROR_4);
+
+            /* Retry if CPUs were added. */
+            if (   cActive != g_cRtMpNtActiveCpus
+                && cTries < 16)
+                continue;
+            MY_CHECK_RETURN(cActive == g_cRtMpNtActiveCpus, /* ASSUMPTION #4 */
+                            ("IPRT: Fatal: cActive=%u != g_cRtMpNtActiveCpus=%u\n", cActive, g_cRtMpNtActiveCpus),
+                            VERR_INTERNAL_ERROR_5);
+        }
+        else
+        {
+            /* Legacy: */
+            MY_CHECK_RETURN(g_cRtMpNtMaxGroups == 1, ("IPRT: Fatal: Missing KeQueryLogicalProcessorRelationship!\n"),
+                            VERR_SYMBOL_NOT_FOUND);
+
+            /** @todo Is it possible that the affinity mask returned by
+             *        KeQueryActiveProcessors is sparse? */
+            if (g_pfnrtKeQueryActiveProcessors)
+                RTCpuSetFromU64(&g_rtMpNtCpuSet, g_pfnrtKeQueryActiveProcessors());
+            else if (g_cRtMpNtMaxCpus < 64)
+                RTCpuSetFromU64(&g_rtMpNtCpuSet, (UINT64_C(1) << g_cRtMpNtMaxCpus) - 1);
+            else
+            {
+                MY_CHECK_RETURN(g_cRtMpNtMaxCpus == 64, ("IPRT: Fatal: g_cRtMpNtMaxCpus=%u, expect 64 or less\n", g_cRtMpNtMaxCpus),
+                                VERR_MP_TOO_MANY_CPUS);
+                RTCpuSetFromU64(&g_rtMpNtCpuSet, UINT64_MAX);
+            }
+
+            g_aRtMpNtCpuGroups[0].cMaxCpus    = g_cRtMpNtMaxCpus;
+            g_aRtMpNtCpuGroups[0].cActiveCpus = g_cRtMpNtMaxCpus;
+            for (unsigned i = 0; i < g_cRtMpNtMaxCpus; i++)
+            {
+                g_aRtMpNtCpuGroups[0].aidxCpuSetMembers[i] = i;
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                g_aidRtMpNtByCpuSetIdx[i] = RTMPCPUID_FROM_GROUP_AND_NUMBER(0, i);
+#endif
+            }
+        }
+
+        /*
+         * Register CPU hot plugging callback (it also counts active CPUs).
+         */
+        Assert(g_pvMpCpuChangeCallback == NULL);
+        if (g_pfnrtKeRegisterProcessorChangeCallback)
+        {
+            MY_CHECK_RETURN(g_pfnrtKeDeregisterProcessorChangeCallback,
+                            ("IPRT: Fatal: KeRegisterProcessorChangeCallback without KeDeregisterProcessorChangeCallback!\n"),
+                            VERR_SYMBOL_NOT_FOUND);
+
+            RTCPUSET const ActiveSetCopy = g_rtMpNtCpuSet;
+            RTCpuSetEmpty(&g_rtMpNtCpuSet);
+            uint32_t const cActiveCpus   = g_cRtMpNtActiveCpus;
+            g_cRtMpNtActiveCpus = 0;
+
+            g_pvMpCpuChangeCallback = g_pfnrtKeRegisterProcessorChangeCallback(rtR0NtMpProcessorChangeCallback, NULL /*pvUser*/,
+                                                                               KE_PROCESSOR_CHANGE_ADD_EXISTING);
+            if (g_pvMpCpuChangeCallback)
+            {
+                if (cActiveCpus == g_cRtMpNtActiveCpus)
+                { /* likely */ }
+                else
+                {
+                    g_pfnrtKeDeregisterProcessorChangeCallback(g_pvMpCpuChangeCallback);
+                    if (cTries < 16)
+                    {
+                        /* Retry if CPUs were added. */
+                        MY_CHECK_RETURN(g_cRtMpNtActiveCpus >= cActiveCpus,
+                                        ("IPRT: Fatal: g_cRtMpNtActiveCpus=%u < cActiveCpus=%u! CPUs removed?\n",
+                                         g_cRtMpNtActiveCpus, cActiveCpus),
+                                        VERR_INTERNAL_ERROR_2);
+                        MY_CHECK_RETURN(g_cRtMpNtActiveCpus <= g_cRtMpNtMaxCpus,
+                                        ("IPRT: Fatal: g_cRtMpNtActiveCpus=%u > g_cRtMpNtMaxCpus=%u!\n",
+                                         g_cRtMpNtActiveCpus, g_cRtMpNtMaxCpus),
+                                        VERR_INTERNAL_ERROR_2);
+                        continue;
+                    }
+                    MY_CHECK_RETURN(0, ("IPRT: Fatal: g_cRtMpNtActiveCpus=%u cActiveCpus=%u\n", g_cRtMpNtActiveCpus, cActiveCpus),
+                                    VERR_INTERNAL_ERROR_3);
+                }
+            }
+            else
+            {
+                AssertFailed();
+                g_rtMpNtCpuSet      = ActiveSetCopy;
+                g_cRtMpNtActiveCpus = cActiveCpus;
+            }
+        }
+        break;
+    } /* Retry loop for stable active CPU count. */
 
-/* test a couple of assumption. */
-AssertCompile(MAXIMUM_PROCESSORS <= RTCPUSET_MAX_CPUS);
-AssertCompile(NIL_RTCPUID >= MAXIMUM_PROCESSORS);
+#undef MY_CHECK_RETURN
 
-/** @todo
- * We cannot do other than assume a 1:1 relationship between the
- * affinity mask and the process despite the vagueness/warnings in
- * the docs. If someone knows a better way to get this done, please
- * let bird know.
+    /*
+     * Special IPI fun for RTMpPokeCpu.
+     *
+     * On Vista and later the DPC method doesn't seem to reliably send IPIs,
+     * so we have to use alternative methods.
+     *
+     * On AMD64 We used to use the HalSendSoftwareInterrupt API (also x86 on
+     * W10+), it looks faster and more convenient to use, however we're either
+     * using it wrong or it doesn't reliably do what we want (see @bugref{8343}).
+     *
+     * The HalRequestIpip API is thus far the only alternative to KeInsertQueueDpc
+     * for doing targetted IPIs.  Trouble with this API is that it changed
+     * fundamentally in Window 7 when they added support for lots of processors.
+     *
+     * If we really think we cannot use KeInsertQueueDpc, we use the broadcast IPI
+     * API KeIpiGenericCall.
+     */
+    if (   pOsVerInfo->uMajorVer > 6
+        || (pOsVerInfo->uMajorVer == 6 && pOsVerInfo->uMinorVer > 0))
+        g_pfnrtHalRequestIpiPreW7 = NULL;
+    else
+        g_pfnrtHalRequestIpiW7Plus = NULL;
+
+    g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingDpc;
+#ifndef IPRT_TARGET_NT4
+    if (   g_pfnrtHalRequestIpiW7Plus
+        && g_pfnrtKeInitializeAffinityEx
+        && g_pfnrtKeAddProcessorAffinityEx
+        && g_pfnrtKeGetProcessorIndexFromNumber)
+    {
+        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingHalReqestIpiW7Plus\n");
+        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingHalReqestIpiW7Plus;
+    }
+    else if (pOsVerInfo->uMajorVer >= 6 && g_pfnrtKeIpiGenericCall)
+    {
+        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingBroadcastIpi\n");
+        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingBroadcastIpi;
+    }
+    else
+        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingDpc\n");
+    /* else: Windows XP should send always send an IPI -> VERIFY */
+#endif
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Called by rtR0TermNative.
  */
+DECLHIDDEN(void) rtR0MpNtTerm(void)
+{
+    /*
+     * Deregister the processor change callback.
+     */
+    PVOID pvMpCpuChangeCallback = g_pvMpCpuChangeCallback;
+    g_pvMpCpuChangeCallback = NULL;
+    if (pvMpCpuChangeCallback)
+    {
+        AssertReturnVoid(g_pfnrtKeDeregisterProcessorChangeCallback);
+        g_pfnrtKeDeregisterProcessorChangeCallback(pvMpCpuChangeCallback);
+    }
+}
+
+
+DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
+{
+    return VINF_SUCCESS;
+}
+
+
+DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
+{
+}
+
+
+/**
+ * Implements the NT PROCESSOR_CALLBACK_FUNCTION callback function.
+ *
+ * This maintains the g_rtMpNtCpuSet and works MP notification callbacks.  When
+ * registered, it's called for each active CPU in the system, avoiding racing
+ * CPU hotplugging (as well as testing the callback).
+ *
+ * @param   pvUser              User context (not used).
+ * @param   pChangeCtx          Change context (in).
+ * @param   prcOperationStatus  Operation status (in/out).
+ *
+ * @remarks ASSUMES no concurrent execution of KeProcessorAddCompleteNotify
+ *          notification callbacks.  At least during callback registration
+ *          callout, we're owning KiDynamicProcessorLock.
+ *
+ * @remarks When registering the handler, we first get KeProcessorAddStartNotify
+ *          callbacks for all active CPUs, and after they all succeed we get the
+ *          KeProcessorAddCompleteNotify callbacks.
+ */
+static VOID __stdcall rtR0NtMpProcessorChangeCallback(void *pvUser, PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT pChangeCtx,
+                                                      PNTSTATUS prcOperationStatus)
+{
+    RT_NOREF(pvUser, prcOperationStatus);
+    switch (pChangeCtx->State)
+    {
+        /*
+         * Check whether we can deal with the CPU, failing the start operation if we
+         * can't.  The checks we are doing here are to avoid complicated/impossible
+         * cases in KeProcessorAddCompleteNotify.  They are really just verify specs.
+         */
+        case KeProcessorAddStartNotify:
+        {
+            NTSTATUS rcNt = STATUS_SUCCESS;
+            if (pChangeCtx->NtNumber < RTCPUSET_MAX_CPUS)
+            {
+                if (pChangeCtx->NtNumber >= g_cRtMpNtMaxCpus)
+                {
+                    DbgPrint("IPRT: KeProcessorAddStartNotify failure: NtNumber=%u is higher than the max CPU count (%u)!\n",
+                             pChangeCtx->NtNumber, g_cRtMpNtMaxCpus);
+                    rcNt = STATUS_INTERNAL_ERROR;
+                }
+
+                /* The ProcessNumber field was introduced in Windows 7. */
+                PROCESSOR_NUMBER ProcNum;
+                if (g_pfnrtKeGetProcessorIndexFromNumber)
+                {
+                    ProcNum = pChangeCtx->ProcNumber;
+                    KEPROCESSORINDEX idxCpu = g_pfnrtKeGetProcessorIndexFromNumber(&ProcNum);
+                    if (idxCpu != pChangeCtx->NtNumber)
+                    {
+                        DbgPrint("IPRT: KeProcessorAddStartNotify failure: g_pfnrtKeGetProcessorIndexFromNumber(%u.%u) -> %u, expected %u!\n",
+                                 ProcNum.Group, ProcNum.Number, idxCpu, pChangeCtx->NtNumber);
+                        rcNt = STATUS_INTERNAL_ERROR;
+                    }
+                }
+                else
+                {
+                    ProcNum.Group  = 0;
+                    ProcNum.Number = pChangeCtx->NtNumber;
+                }
+
+                if (   ProcNum.Group  < RT_ELEMENTS(g_aRtMpNtCpuGroups)
+                    && ProcNum.Number < RT_ELEMENTS(g_aRtMpNtCpuGroups[0].aidxCpuSetMembers))
+                {
+                    if (ProcNum.Group >= g_cRtMpNtMaxGroups)
+                    {
+                        DbgPrint("IPRT: KeProcessorAddStartNotify failure: %u.%u is out of range - max groups: %u!\n",
+                                 ProcNum.Group, ProcNum.Number, g_cRtMpNtMaxGroups);
+                        rcNt = STATUS_INTERNAL_ERROR;
+                    }
+
+                    if (ProcNum.Number < g_aRtMpNtCpuGroups[ProcNum.Group].cMaxCpus)
+                    {
+                        Assert(g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number] != -1);
+                        if (g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number] == -1)
+                        {
+                            DbgPrint("IPRT: KeProcessorAddStartNotify failure: Internal error! %u.%u was assigned -1 as set index!\n",
+                                     ProcNum.Group, ProcNum.Number);
+                            rcNt = STATUS_INTERNAL_ERROR;
+                        }
+
+                        Assert(g_aidRtMpNtByCpuSetIdx[pChangeCtx->NtNumber] != NIL_RTCPUID);
+                        if (g_aidRtMpNtByCpuSetIdx[pChangeCtx->NtNumber] == NIL_RTCPUID)
+                        {
+                            DbgPrint("IPRT: KeProcessorAddStartNotify failure: Internal error! %u (%u.%u) translates to NIL_RTCPUID!\n",
+                                     pChangeCtx->NtNumber, ProcNum.Group, ProcNum.Number);
+                            rcNt = STATUS_INTERNAL_ERROR;
+                        }
+                    }
+                    else
+                    {
+                        DbgPrint("IPRT: KeProcessorAddStartNotify failure: max processors in group %u is %u, cannot add %u to it!\n",
+                                 ProcNum.Group, g_aRtMpNtCpuGroups[ProcNum.Group].cMaxCpus, ProcNum.Group, ProcNum.Number);
+                        rcNt = STATUS_INTERNAL_ERROR;
+                    }
+                }
+                else
+                {
+                    DbgPrint("IPRT: KeProcessorAddStartNotify failure: %u.%u is out of range (max %u.%u)!\n",
+                             ProcNum.Group, ProcNum.Number, RT_ELEMENTS(g_aRtMpNtCpuGroups), RT_ELEMENTS(g_aRtMpNtCpuGroups[0].aidxCpuSetMembers));
+                    rcNt = STATUS_INTERNAL_ERROR;
+                }
+            }
+            else
+            {
+                DbgPrint("IPRT: KeProcessorAddStartNotify failure: NtNumber=%u is outside RTCPUSET_MAX_CPUS (%u)!\n",
+                         pChangeCtx->NtNumber, RTCPUSET_MAX_CPUS);
+                rcNt = STATUS_INTERNAL_ERROR;
+            }
+            if (!NT_SUCCESS(rcNt))
+                *prcOperationStatus = rcNt;
+            break;
+        }
+
+        /*
+         * Update the globals.  Since we've checked out range limits and other
+         * limitations already we just AssertBreak here.
+         */
+        case KeProcessorAddCompleteNotify:
+        {
+            /*
+             * Calc the processor number and assert conditions checked in KeProcessorAddStartNotify.
+             */
+            AssertBreak(pChangeCtx->NtNumber < RTCPUSET_MAX_CPUS);
+            AssertBreak(pChangeCtx->NtNumber < g_cRtMpNtMaxCpus);
+            Assert(pChangeCtx->NtNumber == g_cRtMpNtActiveCpus); /* light assumption */
+            PROCESSOR_NUMBER ProcNum;
+            if (g_pfnrtKeGetProcessorIndexFromNumber)
+            {
+                ProcNum = pChangeCtx->ProcNumber;
+                AssertBreak(g_pfnrtKeGetProcessorIndexFromNumber(&ProcNum) == pChangeCtx->NtNumber);
+                AssertBreak(ProcNum.Group < RT_ELEMENTS(g_aRtMpNtCpuGroups));
+                AssertBreak(ProcNum.Group < g_cRtMpNtMaxGroups);
+            }
+            else
+            {
+                ProcNum.Group  = 0;
+                ProcNum.Number = pChangeCtx->NtNumber;
+            }
+            AssertBreak(ProcNum.Number < RT_ELEMENTS(g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers));
+            AssertBreak(ProcNum.Number < g_aRtMpNtCpuGroups[ProcNum.Group].cMaxCpus);
+            AssertBreak(g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number] != -1);
+            AssertBreak(g_aidRtMpNtByCpuSetIdx[pChangeCtx->NtNumber] != NIL_RTCPUID);
+
+            /*
+             * Add ourselves to the online CPU set and update the active CPU count.
+             */
+            RTCpuSetAddByIndex(&g_rtMpNtCpuSet, pChangeCtx->NtNumber);
+            ASMAtomicIncU32(&g_cRtMpNtActiveCpus);
+
+            /*
+             * Update the group info.
+             *
+             * If the index prediction failed (real hotplugging callbacks only) we
+             * have to switch it around.  This is particularly annoying when we
+             * use the index as the ID.
+             */
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+            RTCPUID idCpu = RTMPCPUID_FROM_GROUP_AND_NUMBER(ProcNum.Group, ProcNum.Number);
+            RTCPUID idOld = g_aidRtMpNtByCpuSetIdx[pChangeCtx->NtNumber];
+            if ((idOld & ~RTMPNT_ID_F_INACTIVE) != idCpu)
+            {
+                Assert(idOld & RTMPNT_ID_F_INACTIVE);
+                int idxDest = g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number];
+                g_aRtMpNtCpuGroups[rtMpCpuIdGetGroup(idOld)].aidxCpuSetMembers[rtMpCpuIdGetGroupMember(idOld)] = idxDest;
+                g_aidRtMpNtByCpuSetIdx[idxDest] = idOld;
+            }
+            g_aidRtMpNtByCpuSetIdx[pChangeCtx->NtNumber] = idCpu;
+#else
+            Assert(g_aidRtMpNtByCpuSetIdx[pChangeCtx->NtNumber] == pChangeCtx->NtNumber);
+            int idxDest = g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number];
+            if ((ULONG)idxDest != pChangeCtx->NtNumber)
+            {
+                bool     fFound = false;
+                uint32_t idxOldGroup = g_cRtMpNtMaxGroups;
+                while (idxOldGroup-- > 0 && !fFound)
+                {
+                    uint32_t idxMember = g_aRtMpNtCpuGroups[idxOldGroup].cMaxCpus;
+                    while (idxMember-- > 0)
+                        if (g_aRtMpNtCpuGroups[idxOldGroup].aidxCpuSetMembers[idxMember] == (int)pChangeCtx->NtNumber)
+                        {
+                            g_aRtMpNtCpuGroups[idxOldGroup].aidxCpuSetMembers[idxMember] = idxDest;
+                            fFound = true;
+                            break;
+                        }
+                }
+                Assert(fFound);
+            }
+#endif
+            g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number] = pChangeCtx->NtNumber;
+
+            /*
+             * Do MP notification callbacks.
+             */
+            rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, pChangeCtx->NtNumber);
+            break;
+        }
+
+        case KeProcessorAddFailureNotify:
+            /* ignore */
+            break;
+
+        default:
+            AssertMsgFailed(("State=%u\n", pChangeCtx->State));
+    }
+}
+
+
+/**
+ * Wrapper around KeQueryLogicalProcessorRelationship.
+ *
+ * @returns IPRT status code.
+ * @param   ppInfo  Where to return the info. Pass to RTMemFree when done.
+ */
+static int rtR0NtInitQueryGroupRelations(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **ppInfo)
+{
+    ULONG    cbInfo = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)
+                    + g_cRtMpNtMaxGroups * sizeof(GROUP_RELATIONSHIP);
+    NTSTATUS rcNt;
+    do
+    {
+        SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)RTMemAlloc(cbInfo);
+        if (pInfo)
+        {
+            rcNt = g_pfnrtKeQueryLogicalProcessorRelationship(NULL /*pProcNumber*/, RelationGroup, pInfo, &cbInfo);
+            if (NT_SUCCESS(rcNt))
+            {
+                *ppInfo = pInfo;
+                return VINF_SUCCESS;
+            }
+
+            RTMemFree(pInfo);
+            pInfo = NULL;
+        }
+        else
+            rcNt = STATUS_NO_MEMORY;
+    } while (rcNt == STATUS_INFO_LENGTH_MISMATCH);
+    DbgPrint("IPRT: Fatal: KeQueryLogicalProcessorRelationship failed: %#x\n", rcNt);
+    AssertMsgFailed(("KeQueryLogicalProcessorRelationship failed: %#x\n", rcNt));
+    return RTErrConvertFromNtStatus(rcNt);
+}
+
+
+
 
 
 RTDECL(RTCPUID) RTMpCpuId(void)
 {
-    /* WDK upgrade warning: PCR->Number changed from BYTE to WORD. */
-    return KeGetCurrentProcessorNumber();
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    PROCESSOR_NUMBER ProcNum;
+    ProcNum.Group = 0;
+    if (g_pfnrtKeGetCurrentProcessorNumberEx)
+    {
+        ProcNum.Number = 0;
+        g_pfnrtKeGetCurrentProcessorNumberEx(&ProcNum);
+    }
+    else
+        ProcNum.Number = KeGetCurrentProcessorNumber(); /* Number is 8-bit, so we're not subject to BYTE -> WORD upgrade in WDK.  */
+    return RTMPCPUID_FROM_GROUP_AND_NUMBER(ProcNum.Group, ProcNum.Number);
+
+#else
+
+    if (g_pfnrtKeGetCurrentProcessorNumberEx)
+    {
+        KEPROCESSORINDEX idxCpu = g_pfnrtKeGetCurrentProcessorNumberEx(NULL);
+        Assert(idxCpu < RTCPUSET_MAX_CPUS);
+        return idxCpu;
+    }
+
+    return (uint8_t)KeGetCurrentProcessorNumber(); /* PCR->Number was changed from BYTE to WORD in the WDK, thus the cast. */
+#endif
 }
 
 
 RTDECL(int) RTMpCurSetIndex(void)
 {
-    /* WDK upgrade warning: PCR->Number changed from BYTE to WORD. */
-    return KeGetCurrentProcessorNumber();
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+    if (g_pfnrtKeGetCurrentProcessorNumberEx)
+    {
+        KEPROCESSORINDEX idxCpu = g_pfnrtKeGetCurrentProcessorNumberEx(NULL);
+        Assert(idxCpu < RTCPUSET_MAX_CPUS);
+        return idxCpu;
+    }
+    return (uint8_t)KeGetCurrentProcessorNumber(); /* PCR->Number was changed from BYTE to WORD in the WDK, thus the cast. */
+#else
+    return (int)RTMpCpuId();
+#endif
 }
 
 
 RTDECL(int) RTMpCurSetIndexAndId(PRTCPUID pidCpu)
 {
-    return *pidCpu = KeGetCurrentProcessorNumber();
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+    PROCESSOR_NUMBER ProcNum = { 0 , 0,  0 };
+    KEPROCESSORINDEX idxCpu = g_pfnrtKeGetCurrentProcessorNumberEx(&ProcNum);
+    Assert(idxCpu < RTCPUSET_MAX_CPUS);
+    *pidCpu = RTMPCPUID_FROM_GROUP_AND_NUMBER(ProcNum.Group, ProcNum.Number);
+    return idxCpu;
+#else
+    return *pidCpu = RTMpCpuId();
+#endif
 }
 
 
 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
 {
-    return idCpu < MAXIMUM_PROCESSORS ? (int)idCpu : -1;
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+    if (idCpu != NIL_RTCPUID)
+    {
+        if (g_pfnrtKeGetProcessorIndexFromNumber)
+        {
+            PROCESSOR_NUMBER ProcNum;
+            ProcNum.Group    = rtMpCpuIdGetGroup(idCpu);
+            ProcNum.Number   = rtMpCpuIdGetGroupMember(idCpu);
+            ProcNum.Reserved = 0;
+            KEPROCESSORINDEX idxCpu = g_pfnrtKeGetProcessorIndexFromNumber(&ProcNum);
+            if (idxCpu != INVALID_PROCESSOR_INDEX)
+            {
+                Assert(idxCpu < g_cRtMpNtMaxCpus);
+                Assert((ULONG)g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number] == idxCpu);
+                return idxCpu;
+            }
+
+            /* Since NT assigned indexes as the CPUs come online, we cannot produce an ID <-> index
+               mapping for not-yet-onlined CPUS that is consistent.  We just have to do our best... */
+            if (   ProcNum.Group < g_cRtMpNtMaxGroups
+                && ProcNum.Number < g_aRtMpNtCpuGroups[ProcNum.Group].cMaxCpus)
+                return g_aRtMpNtCpuGroups[ProcNum.Group].aidxCpuSetMembers[ProcNum.Number];
+        }
+        else if (rtMpCpuIdGetGroup(idCpu) == 0)
+            return rtMpCpuIdGetGroupMember(idCpu);
+    }
+    return -1;
+#else
+    /* 1:1 mapping, just do range checks. */
+    return idCpu < RTCPUSET_MAX_CPUS ? (int)idCpu : -1;
+#endif
 }
 
 
 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
 {
-    return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID;
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+    if ((unsigned)iCpu < g_cRtMpNtMaxCpus)
+    {
+        if (g_pfnrtKeGetProcessorIndexFromNumber)
+        {
+            PROCESSOR_NUMBER ProcNum = { 0, 0, 0 };
+            NTSTATUS rcNt = g_pfnrtKeGetProcessorNumberFromIndex(iCpu, &ProcNum);
+            if (NT_SUCCESS(rcNt))
+            {
+                Assert(ProcNum.Group <= g_cRtMpNtMaxGroups);
+                Assert(   (g_aidRtMpNtByCpuSetIdx[iCpu] & ~RTMPNT_ID_F_INACTIVE)
+                       == RTMPCPUID_FROM_GROUP_AND_NUMBER(ProcNum.Group, ProcNum.Number));
+                return RTMPCPUID_FROM_GROUP_AND_NUMBER(ProcNum.Group, ProcNum.Number);
+            }
+        }
+        return g_aidRtMpNtByCpuSetIdx[iCpu];
+    }
+    return NIL_RTCPUID;
+#else
+    /* 1:1 mapping, just do range checks. */
+    return (unsigned)iCpu < RTCPUSET_MAX_CPUS ? iCpu : NIL_RTCPUID;
+#endif
 }
 
 
-RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
+RTDECL(int) RTMpSetIndexFromCpuGroupMember(uint32_t idxGroup, uint32_t idxMember)
 {
-    /** @todo use KeQueryMaximumProcessorCount on vista+ */
-    return MAXIMUM_PROCESSORS - 1;
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+    if (idxGroup < g_cRtMpNtMaxGroups)
+        if (idxMember < g_aRtMpNtCpuGroups[idxGroup].cMaxCpus)
+            return g_aRtMpNtCpuGroups[idxGroup].aidxCpuSetMembers[idxMember];
+    return -1;
 }
 
 
-RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
+RTDECL(uint32_t) RTMpGetCpuGroupCounts(uint32_t idxGroup, uint32_t *pcActive)
 {
-    if (idCpu >= MAXIMUM_PROCESSORS)
-        return false;
+    if (idxGroup < g_cRtMpNtMaxGroups)
+    {
+        if (pcActive)
+            *pcActive = g_aRtMpNtCpuGroups[idxGroup].cActiveCpus;
+        return g_aRtMpNtCpuGroups[idxGroup].cMaxCpus;
+    }
+    if (pcActive)
+        *pcActive = 0;
+    return 0;
+}
+
 
-#if 0 /* this isn't safe at all IRQLs (great work guys) */
-    KAFFINITY Mask = KeQueryActiveProcessors();
-    return !!(Mask & RT_BIT_64(idCpu));
+RTDECL(uint32_t) RTMpGetMaxCpuGroupCount(void)
+{
+    return g_cRtMpNtMaxGroups;
+}
+
+
+RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
+{
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    return RTMPCPUID_FROM_GROUP_AND_NUMBER(g_cRtMpNtMaxGroups - 1, g_aRtMpNtCpuGroups[g_cRtMpNtMaxGroups - 1].cMaxCpus - 1);
 #else
-    return RTCpuSetIsMember(&g_rtMpNtCpuSet, idCpu);
+    /* According to MSDN the processor indexes goes from 0 to the maximum
+       number of CPUs in the system.  We've check this in initterm-r0drv-nt.cpp. */
+    return g_cRtMpNtMaxCpus - 1;
 #endif
 }
 
 
+RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
+{
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+    return RTCpuSetIsMember(&g_rtMpNtCpuSet, idCpu);
+}
+
+
 RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
 {
-    /* Cannot easily distinguish between online and offline cpus. */
-    /** @todo online/present cpu stuff must be corrected for proper W2K8 support
-     *        (KeQueryMaximumProcessorCount). */
-    return RTMpIsCpuOnline(idCpu);
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    if (idCpu != NIL_RTCPUID)
+    {
+        unsigned idxGroup = rtMpCpuIdGetGroup(idCpu);
+        if (idxGroup < g_cRtMpNtMaxGroups)
+            return rtMpCpuIdGetGroupMember(idCpu) < g_aRtMpNtCpuGroups[idxGroup].cMaxCpus;
+    }
+    return false;
+
+#else
+    /* A possible CPU ID is one with a value lower than g_cRtMpNtMaxCpus (see
+       comment in RTMpGetMaxCpuId). */
+    return idCpu < g_cRtMpNtMaxCpus;
+#endif
 }
 
 
 
 RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
 {
-    /** @todo online/present cpu stuff must be corrected for proper W2K8 support
-     *        (KeQueryMaximumProcessorCount). */
-    return RTMpGetOnlineSet(pSet);
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
+    /* The set of possible CPU IDs(/indexes) are from 0 up to
+       g_cRtMpNtMaxCpus (see comment in RTMpGetMaxCpuId). */
+    RTCpuSetEmpty(pSet);
+    int idxCpu = g_cRtMpNtMaxCpus;
+    while (idxCpu-- > 0)
+        RTCpuSetAddByIndex(pSet, idxCpu);
+    return pSet;
 }
 
 
 RTDECL(RTCPUID) RTMpGetCount(void)
 {
-    /** @todo online/present cpu stuff must be corrected for proper W2K8 support
-     *        (KeQueryMaximumProcessorCount). */
-    return RTMpGetOnlineCount();
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+    return g_cRtMpNtMaxCpus;
 }
 
 
 RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
 {
-#if 0 /* this isn't safe at all IRQLs (great work guys) */
-    KAFFINITY Mask = KeQueryActiveProcessors();
-    return RTCpuSetFromU64(pSet, Mask);
-#else
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
     *pSet = g_rtMpNtCpuSet;
     return pSet;
-#endif
 }
 
 
@@ -186,6 +1134,14 @@ RTDECL(RTCPUID) RTMpGetOnlineCount(void)
 }
 
 
+RTDECL(RTCPUID) RTMpGetOnlineCoreCount(void)
+{
+    /** @todo fix me */
+    return RTMpGetOnlineCount();
+}
+
+
+
 #if 0
 /* Experiment with checking the undocumented KPRCB structure
  * 'dt nt!_kprcb 0xaddress' shows the layout
@@ -235,7 +1191,7 @@ static ULONG_PTR rtmpNtOnAllBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 {
     PRTMPARGS pArgs = (PRTMPARGS)uUserCtx;
     /*ASMAtomicIncU32(&pArgs->cHits); - not needed */
-    pArgs->pfnWorker(KeGetCurrentProcessorNumber(), pArgs->pvUser1, pArgs->pvUser2);
+    pArgs->pfnWorker(RTMpCpuId(), pArgs->pvUser1, pArgs->pvUser2);
     return 0;
 }
 
@@ -249,7 +1205,7 @@ static ULONG_PTR rtmpNtOnAllBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 static ULONG_PTR rtmpNtOnOthersBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 {
     PRTMPARGS pArgs = (PRTMPARGS)uUserCtx;
-    RTCPUID idCpu = KeGetCurrentProcessorNumber();
+    RTCPUID idCpu = RTMpCpuId();
     if (pArgs->idCpu != idCpu)
     {
         /*ASMAtomicIncU32(&pArgs->cHits); - not needed */
@@ -268,7 +1224,7 @@ static ULONG_PTR rtmpNtOnOthersBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 static ULONG_PTR rtmpNtOnPairBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 {
     PRTMPARGS pArgs = (PRTMPARGS)uUserCtx;
-    RTCPUID idCpu = KeGetCurrentProcessorNumber();
+    RTCPUID idCpu = RTMpCpuId();
     if (   pArgs->idCpu  == idCpu
         || pArgs->idCpu2 == idCpu)
     {
@@ -288,7 +1244,7 @@ static ULONG_PTR rtmpNtOnPairBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 static ULONG_PTR rtmpNtOnSpecificBroadcastIpiWrapper(ULONG_PTR uUserCtx)
 {
     PRTMPARGS pArgs = (PRTMPARGS)uUserCtx;
-    RTCPUID idCpu = KeGetCurrentProcessorNumber();
+    RTCPUID idCpu = RTMpCpuId();
     if (pArgs->idCpu == idCpu)
     {
         ASMAtomicIncU32(&pArgs->cHits);
@@ -347,7 +1303,7 @@ static VOID rtmpNtDPCWrapper(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID Sy
     RT_NOREF3(Dpc, SystemArgument1, SystemArgument2);
 
     ASMAtomicIncU32(&pArgs->cHits);
-    pArgs->pfnWorker(KeGetCurrentProcessorNumber(), pArgs->pvUser1, pArgs->pvUser2);
+    pArgs->pfnWorker(RTMpCpuId(), pArgs->pvUser1, pArgs->pvUser2);
 
     /* Dereference the argument structure. */
     int32_t cRefs = ASMAtomicDecS32(&pArgs->cRefs);
@@ -358,6 +1314,38 @@ static VOID rtmpNtDPCWrapper(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID Sy
 
 
 /**
+ * Wrapper around KeSetTargetProcessorDpcEx / KeSetTargetProcessorDpc.
+ *
+ * This is shared with the timer code.
+ *
+ * @returns IPRT status code (errors are asserted).
+ * @param   pDpc                The DPC.
+ * @param   idCpu               The ID of the new target CPU.
+ */
+DECLHIDDEN(int) rtMpNtSetTargetProcessorDpc(KDPC *pDpc, RTCPUID idCpu)
+{
+    if (g_pfnrtKeSetTargetProcessorDpcEx)
+    {
+        /* Convert to stupid process number (bet KeSetTargetProcessorDpcEx does
+           the reverse conversion internally). */
+        PROCESSOR_NUMBER ProcNum;
+        NTSTATUS rcNt = g_pfnrtKeGetProcessorNumberFromIndex(RTMpCpuIdToSetIndex(idCpu), &ProcNum);
+        AssertMsgReturn(NT_SUCCESS(rcNt),
+                        ("KeGetProcessorNumberFromIndex(%u) -> %#x\n", idCpu, rcNt),
+                        RTErrConvertFromNtStatus(rcNt));
+
+        rcNt = g_pfnrtKeSetTargetProcessorDpcEx(pDpc, &ProcNum);
+        AssertMsgReturn(NT_SUCCESS(rcNt),
+                        ("KeSetTargetProcessorDpcEx(,%u(%u/%u)) -> %#x\n", idCpu, ProcNum.Group, ProcNum.Number, rcNt),
+                        RTErrConvertFromNtStatus(rcNt));
+    }
+    else
+        KeSetTargetProcessorDpc(pDpc, RTMpCpuIdToSetIndex(idCpu));
+    return VINF_SUCCESS;
+}
+
+
+/**
  * Internal worker for the RTMpOn* APIs.
  *
  * @returns IPRT status code.
@@ -379,23 +1367,44 @@ static int rtMpCallUsingDpcs(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUse
     return VERR_NOT_SUPPORTED;
 
 #else  /* !IPRT_TARGET_NT4 */
-    PRTMPARGS pArgs;
-    KDPC     *paExecCpuDpcs;
-
 # if 0
     /* KeFlushQueuedDpcs must be run at IRQL PASSIVE_LEVEL according to MSDN, but the
      * driver verifier doesn't complain...
      */
     AssertMsg(KeGetCurrentIrql() == PASSIVE_LEVEL, ("%d != %d (PASSIVE_LEVEL)\n", KeGetCurrentIrql(), PASSIVE_LEVEL));
 # endif
-
-    KAFFINITY Mask = KeQueryActiveProcessors();
-
     /* KeFlushQueuedDpcs is not present in Windows 2000; import it dynamically so we can just fail this call. */
     if (!g_pfnrtNtKeFlushQueuedDpcs)
         return VERR_NOT_SUPPORTED;
 
-    pArgs = (PRTMPARGS)ExAllocatePoolWithTag(NonPagedPool, MAXIMUM_PROCESSORS*sizeof(KDPC) + sizeof(RTMPARGS), (ULONG)'RTMp');
+    /*
+     * Make a copy of the active CPU set and figure out how many KDPCs we really need.
+     * We must not try setup DPCs for CPUs which aren't there, because that may fail.
+     */
+    RTCPUSET  OnlineSet = g_rtMpNtCpuSet;
+    uint32_t  cDpcsNeeded;
+    switch (enmCpuid)
+    {
+        case RT_NT_CPUID_SPECIFIC:
+            cDpcsNeeded = 1;
+            break;
+        case RT_NT_CPUID_PAIR:
+            cDpcsNeeded = 2;
+            break;
+        default:
+            do
+            {
+                cDpcsNeeded = g_cRtMpNtActiveCpus;
+                OnlineSet   = g_rtMpNtCpuSet;
+            } while (cDpcsNeeded != g_cRtMpNtActiveCpus);
+            break;
+    }
+
+    /*
+     * Allocate an RTMPARGS structure followed by cDpcsNeeded KDPCs
+     * and initialize them.
+     */
+    PRTMPARGS pArgs = (PRTMPARGS)ExAllocatePoolWithTag(NonPagedPool, sizeof(RTMPARGS) + cDpcsNeeded * sizeof(KDPC), (ULONG)'RTMp');
     if (!pArgs)
         return VERR_NO_MEMORY;
 
@@ -407,38 +1416,47 @@ static int rtMpCallUsingDpcs(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUse
     pArgs->cHits     = 0;
     pArgs->cRefs     = 1;
 
-    paExecCpuDpcs = (KDPC *)(pArgs + 1);
-
+    int rc;
+    KDPC *paExecCpuDpcs = (KDPC *)(pArgs + 1);
     if (enmCpuid == RT_NT_CPUID_SPECIFIC)
     {
         KeInitializeDpc(&paExecCpuDpcs[0], rtmpNtDPCWrapper, pArgs);
         KeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
-        KeSetTargetProcessorDpc(&paExecCpuDpcs[0], (int)idCpu);
+        rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[0], idCpu);
         pArgs->idCpu = idCpu;
     }
     else if (enmCpuid == RT_NT_CPUID_PAIR)
     {
         KeInitializeDpc(&paExecCpuDpcs[0], rtmpNtDPCWrapper, pArgs);
         KeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
-        KeSetTargetProcessorDpc(&paExecCpuDpcs[0], (int)idCpu);
+        rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[0], idCpu);
         pArgs->idCpu = idCpu;
 
         KeInitializeDpc(&paExecCpuDpcs[1], rtmpNtDPCWrapper, pArgs);
         KeSetImportanceDpc(&paExecCpuDpcs[1], HighImportance);
-        KeSetTargetProcessorDpc(&paExecCpuDpcs[1], (int)idCpu2);
+        if (RT_SUCCESS(rc))
+            rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[1], (int)idCpu2);
         pArgs->idCpu2 = idCpu2;
     }
     else
     {
-        for (unsigned i = 0; i < MAXIMUM_PROCESSORS; i++)
-        {
-            KeInitializeDpc(&paExecCpuDpcs[i], rtmpNtDPCWrapper, pArgs);
-            KeSetImportanceDpc(&paExecCpuDpcs[i], HighImportance);
-            KeSetTargetProcessorDpc(&paExecCpuDpcs[i], i);
-        }
+        rc = VINF_SUCCESS;
+        for (uint32_t i = 0; i < cDpcsNeeded && RT_SUCCESS(rc); i++)
+            if (RTCpuSetIsMemberByIndex(&OnlineSet, i))
+            {
+                KeInitializeDpc(&paExecCpuDpcs[i], rtmpNtDPCWrapper, pArgs);
+                KeSetImportanceDpc(&paExecCpuDpcs[i], HighImportance);
+                rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[i], RTMpCpuIdFromSetIndex(i));
+            }
+    }
+    if (RT_FAILURE(rc))
+    {
+        ExFreePool(pArgs);
+        return rc;
     }
 
-    /* Raise the IRQL to DISPATCH_LEVEL so we can't be rescheduled to another cpu.
+    /*
+     * Raise the IRQL to DISPATCH_LEVEL so we can't be rescheduled to another cpu.
      * KeInsertQueueDpc must also be executed at IRQL >= DISPATCH_LEVEL.
      */
     KIRQL oldIrql;
@@ -468,12 +1486,11 @@ static int rtMpCallUsingDpcs(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUse
     }
     else
     {
-        unsigned iSelf = KeGetCurrentProcessorNumber();
-
-        for (unsigned i = 0; i < MAXIMUM_PROCESSORS; i++)
+        uint32_t iSelf = RTMpCurSetIndex();
+        for (uint32_t i = 0; i < cDpcsNeeded; i++)
         {
-            if (    (i != iSelf)
-                &&  (Mask & RT_BIT_64(i)))
+            if (   (i != iSelf)
+                && RTCpuSetIsMemberByIndex(&OnlineSet, i))
             {
                 ASMAtomicIncS32(&pArgs->cRefs);
                 BOOLEAN fRc = KeInsertQueueDpc(&paExecCpuDpcs[i], 0, 0);
@@ -486,7 +1503,9 @@ static int rtMpCallUsingDpcs(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUse
 
     KeLowerIrql(oldIrql);
 
-    /* Flush all DPCs and wait for completion. (can take long!) */
+    /*
+     * Flush all DPCs and wait for completion. (can take long!)
+     */
     /** @todo Consider changing this to an active wait using some atomic inc/dec
      *  stuff (and check for the current cpu above in the specific case). */
     /** @todo Seems KeFlushQueuedDpcs doesn't wait for the DPCs to be completely
@@ -504,7 +1523,7 @@ static int rtMpCallUsingDpcs(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUse
         ExFreePool(pArgs);
 
     return VINF_SUCCESS;
-#endif /* */
+#endif /* !IPRT_TARGET_NT4 */
 }
 
 
@@ -610,7 +1629,7 @@ static VOID rtMpNtOnSpecificDpcWrapper(IN PKDPC Dpc, IN PVOID DeferredContext,
 
     ASMAtomicWriteBool(&pArgs->fExecuting, true);
 
-    pArgs->CallbackArgs.pfnWorker(KeGetCurrentProcessorNumber(), pArgs->CallbackArgs.pvUser1, pArgs->CallbackArgs.pvUser2);
+    pArgs->CallbackArgs.pfnWorker(RTMpCpuId(), pArgs->CallbackArgs.pvUser1, pArgs->CallbackArgs.pvUser2);
 
     ASMAtomicWriteBool(&pArgs->fDone, true);
     KeSetEvent(&pArgs->DoneEvt, 1 /*PriorityIncrement*/, FALSE /*Wait*/);
@@ -682,7 +1701,12 @@ RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1
     KeInitializeEvent(&pArgs->DoneEvt, SynchronizationEvent, FALSE /* not signalled */);
     KeInitializeDpc(&pArgs->Dpc, rtMpNtOnSpecificDpcWrapper, pArgs);
     KeSetImportanceDpc(&pArgs->Dpc, HighImportance);
-    KeSetTargetProcessorDpc(&pArgs->Dpc, (int)idCpu);
+    rc = rtMpNtSetTargetProcessorDpc(&pArgs->Dpc, idCpu);
+    if (RT_FAILURE(rc))
+    {
+        ExFreePool(pArgs);
+        return rc;
+    }
 
     /*
      * Disable preemption while we check the current processor and inserts the DPC.
@@ -831,15 +1855,10 @@ int rtMpPokeCpuUsingBroadcastIpi(RTCPUID idCpu)
  */
 int rtMpPokeCpuUsingHalReqestIpiW7Plus(RTCPUID idCpu)
 {
-    /*
-     * I think we'll let idCpu be an NT processor number and not a HAL processor
-     * index.  KeAddProcessorAffinityEx is for HAL and uses HAL processor
-     * indexes as input from what I can tell.
-     */
-    PROCESSOR_NUMBER ProcNumber = { /*Group=*/ idCpu / 64, /*Number=*/ idCpu % 64, /* Reserved=*/ 0};
-    KAFFINITY_EX     Target;
+    /* idCpu is an HAL processor index, so we can use it directly. */
+    KAFFINITY_EX Target;
     g_pfnrtKeInitializeAffinityEx(&Target);
-    g_pfnrtKeAddProcessorAffinityEx(&Target, g_pfnrtKeGetProcessorIndexFromNumber(&ProcNumber));
+    g_pfnrtKeAddProcessorAffinityEx(&Target, idCpu);
 
     g_pfnrtHalRequestIpiW7Plus(0, &Target);
     return VINF_SUCCESS;
@@ -867,20 +1886,25 @@ int rtMpPokeCpuUsingHalReqestIpiPreW7(RTCPUID idCpu)
 
 int rtMpPokeCpuUsingDpc(RTCPUID idCpu)
 {
+    Assert(g_cRtMpNtMaxCpus > 0 && g_cRtMpNtMaxGroups > 0); /* init order */
+
     /*
      * APC fallback.
      */
-    static KDPC s_aPokeDpcs[MAXIMUM_PROCESSORS] = {0};
+    static KDPC s_aPokeDpcs[RTCPUSET_MAX_CPUS] = {0};
     static bool s_fPokeDPCsInitialized = false;
 
     if (!s_fPokeDPCsInitialized)
     {
-        for (unsigned i = 0; i < RT_ELEMENTS(s_aPokeDpcs); i++)
+        for (unsigned i = 0; i < g_cRtMpNtMaxCpus; i++)
         {
             KeInitializeDpc(&s_aPokeDpcs[i], rtMpNtPokeCpuDummy, NULL);
             KeSetImportanceDpc(&s_aPokeDpcs[i], HighImportance);
-            KeSetTargetProcessorDpc(&s_aPokeDpcs[i], (int)i);
+            int rc = rtMpNtSetTargetProcessorDpc(&s_aPokeDpcs[i], idCpu);
+            if (RT_FAILURE(rc))
+                return rc;
         }
+
         s_fPokeDPCsInitialized = true;
     }
 
@@ -909,7 +1933,7 @@ RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
         return !RTMpIsCpuPossible(idCpu)
               ? VERR_CPU_NOT_FOUND
               : VERR_CPU_OFFLINE;
-    /* Calls rtMpSendIpiFallback, rtMpSendIpiWin7AndLater or rtMpSendIpiVista. */
+    /* Calls rtMpPokeCpuUsingDpc, rtMpPokeCpuUsingHalReqestIpiW7Plus or rtMpPokeCpuUsingBroadcastIpi. */
     return g_pfnrtMpPokeCpuWorker(idCpu);
 }
 
diff --git a/src/VBox/Runtime/r0drv/nt/mpnotification-r0drv-nt.cpp b/src/VBox/Runtime/r0drv/nt/mpnotification-r0drv-nt.cpp
deleted file mode 100644
index 6d40c5d..0000000
--- a/src/VBox/Runtime/r0drv/nt/mpnotification-r0drv-nt.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/* $Id: mpnotification-r0drv-nt.cpp $ */
-/** @file
- * IPRT - Multiprocessor Event Notifications, Ring-0 Driver, NT.
- */
-
-/*
- * Copyright (C) 2008-2016 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * The contents of this file may alternatively be used under the terms
- * of the Common Development and Distribution License Version 1.0
- * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
- * VirtualBox OSE distribution, in which case the provisions of the
- * CDDL are applicable instead of those of the GPL.
- *
- * You may elect to license modified versions of this file under the
- * terms and conditions of either the GPL or the CDDL or both.
- */
-
-
-/*********************************************************************************************************************************
-*   Header Files                                                                                                                 *
-*********************************************************************************************************************************/
-#include "the-nt-kernel.h"
-
-#include <iprt/mp.h>
-#include <iprt/err.h>
-#include <iprt/cpuset.h>
-#include "r0drv/mp-r0drv.h"
-#include "internal-r0drv-nt.h"
-
-
-#if 0 /* The following is 100% untested code . */
-
-#ifndef KE_PROCESSOR_CHANGE_ADD_EXISTING
-/* Some bits that are missing from our DDK headers. */
-
-typedef enum
-{
-    KeProcessorAddStartNotify = 0,
-    KeProcessorAddCompleteNotify,
-    KeProcessorAddFailureNotify
-} KE_PROCESSOR_CHANGE_NOTIFY_STATE;
-
-typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT
-{
-    KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
-    ULONG NtNumber;
-    NTSTATUS Status;
-} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
-typedef KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
-
-typedef VOID (__stdcall *PPROCESSOR_CALLBACK_FUNCTION)(PVOID, PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, PNTSTATUS);
-
-# define KE_PROCESSOR_CHANGE_ADD_EXISTING 1
-#endif /* !KE_PROCESSOR_CHANGE_ADD_EXISTING */
-
-
-
-/*********************************************************************************************************************************
-*   Structures and Typedefs                                                                                                      *
-*********************************************************************************************************************************/
-/** Typedef of KeRegisterProcessorChangeCallback. */
-typedef PVOID (__stdcall *PFNMYKEREGISTERPROCESSORCHANGECALLBACK)(PPROCESSOR_CALLBACK_FUNCTION, PVOID, ULONG);
-/** Typedef of KeDeregisterProcessorChangeCallback. */
-typedef VOID (__stdcall *PFNMYKEDEREGISTERPROCESSORCHANGECALLBACK)(PVOID);
-
-
-/*********************************************************************************************************************************
-*   Global Variables                                                                                                             *
-*********************************************************************************************************************************/
-/** The pointer to KeRegisterProcessorChangeCallback if found. */
-static PFNMYKEREGISTERPROCESSORCHANGECALLBACK   g_pfnKeRegisterProcessorChangeCallback = NULL;
-/** The pointer to KeDeregisterProcessorChangeCallback if found. */
-static PFNMYKEDEREGISTERPROCESSORCHANGECALLBACK g_pfnKeDeregisterProcessorChangeCallback = NULL;
-/** The callback handle. */
-static PVOID g_hCallback = NULL;
-
-
-/**
- * The native callback.
- *
- * @param   pNotifierBlock  Pointer to g_NotifierBlock.
- * @param   ulNativeEvent   The native event.
- * @param   pvCpu           The cpu id cast into a pointer value.
- */
-static VOID __stdcall rtMpNotificationNtCallback(PVOID pvUser,
-                                                 PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT pChangeContext,
-                                                 PNTSTATUS pOperationStatus)
-{
-    NOREF(pvUser);
-    AssertPtr(pChangeContext);
-    AssertPtrNull(pOperationStatus);
-
-    RTCPUID idCpu = pChangeContext->NtNumber;
-    switch (pChangeContext->State)
-    {
-        case KeProcessorAddStartNotify:
-        case KeProcessorAddFailureNotify:
-            break;
-
-        case KeProcessorAddCompleteNotify:
-            /* Update the active CPU set before doing callback round. */
-            RTCpuSetAdd(&g_rtMpNtCpuSet, idCpu);
-            rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, idCpu);
-            break;
-
-        //case KeProcessorDelCompleteNotify:
-        //    rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, idCpu);
-        //    break;
-
-        default:
-           AssertMsgFailed(("Unexpected state=%d idCpu=%d\n", pChangeContext->State, (int)idCpu));
-           break;
-    }
-
-    *pOperationStatus = STATUS_SUCCESS;
-}
-
-
-DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
-{
-    /*
-     * Try resolve the symbols.
-     */
-    UNICODE_STRING RoutineName;
-    RtlInitUnicodeString(&RoutineName, L"KeRegisterProcessorChangeCallback");
-    g_pfnKeRegisterProcessorChangeCallback = (PFNMYKEREGISTERPROCESSORCHANGECALLBACK)MmGetSystemRoutineAddress(&RoutineName);
-    if (g_pfnKeRegisterProcessorChangeCallback)
-    {
-        RtlInitUnicodeString(&RoutineName, L"KeDeregisterProcessorChangeCallback");
-        g_pfnKeDeregisterProcessorChangeCallback = (PFNMYKEDEREGISTERPROCESSORCHANGECALLBACK)MmGetSystemRoutineAddress(&RoutineName);
-        if (g_pfnKeDeregisterProcessorChangeCallback)
-        {
-            /*
-             * Try call it.
-             */
-            NTSTATUS ntRc = 0;
-            g_hCallback = g_pfnKeRegisterProcessorChangeCallback(rtMpNotificationNtCallback, &ntRc, KE_PROCESSOR_CHANGE_ADD_EXISTING);
-            if (g_hCallback != NULL)
-                return VINF_SUCCESS;
-
-            /* Genuine failure. */
-            int rc = RTErrConvertFromNtStatus(ntRc);
-            AssertMsgFailed(("ntRc=%#x rc=%d\n", ntRc, rc));
-            return rc;
-        }
-
-        /* this shouldn't happen. */
-        AssertFailed();
-    }
-
-    /* Not supported - success. */
-    g_pfnKeRegisterProcessorChangeCallback = NULL;
-    g_pfnKeDeregisterProcessorChangeCallback = NULL;
-    return VINF_SUCCESS;
-}
-
-
-DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
-{
-    if (    g_pfnKeDeregisterProcessorChangeCallback
-        &&  g_hCallback)
-    {
-        g_pfnKeDeregisterProcessorChangeCallback(g_hCallback);
-        g_hCallback = NULL;
-    }
-}
-
-#else   /* Not supported */
-
-DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
-{
-    return VINF_SUCCESS;
-}
-
-DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
-{
-}
-
-#endif  /* Not supported */
-
diff --git a/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp b/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp
index 387d91b..5bfbe81 100644
--- a/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp
+++ b/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp
@@ -510,6 +510,7 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_
     pTimer->pvUser = pvUser;
     pTimer->u64NanoInterval = u64NanoInterval;
     KeInitializeTimerEx(&pTimer->NtTimer, SynchronizationTimer);
+    int rc = VINF_SUCCESS;
     if (pTimer->fOmniTimer)
     {
         /*
@@ -518,7 +519,7 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_
          * ASSUMES that no cpus will ever go offline.
          */
         pTimer->idCpu = NIL_RTCPUID;
-        for (unsigned iCpu = 0; iCpu < cSubTimers; iCpu++)
+        for (unsigned iCpu = 0; iCpu < cSubTimers && RT_SUCCESS(rc); iCpu++)
         {
             pTimer->aSubTimers[iCpu].iTick = 0;
             pTimer->aSubTimers[iCpu].pParent = pTimer;
@@ -532,7 +533,7 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_
             else
                 KeInitializeDpc(&pTimer->aSubTimers[iCpu].NtDpc, rtTimerNtOmniSlaveCallback, &pTimer->aSubTimers[iCpu]);
             KeSetImportanceDpc(&pTimer->aSubTimers[iCpu].NtDpc, HighImportance);
-            KeSetTargetProcessorDpc(&pTimer->aSubTimers[iCpu].NtDpc, (int)RTMpCpuIdFromSetIndex(iCpu));
+            rc = rtMpNtSetTargetProcessorDpc(&pTimer->aSubTimers[iCpu].NtDpc, iCpu);
         }
         Assert(pTimer->idCpu != NIL_RTCPUID);
     }
@@ -548,11 +549,16 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_
         KeInitializeDpc(&pTimer->aSubTimers[0].NtDpc, rtTimerNtSimpleCallback, pTimer);
         KeSetImportanceDpc(&pTimer->aSubTimers[0].NtDpc, HighImportance);
         if (pTimer->fSpecificCpu)
-            KeSetTargetProcessorDpc(&pTimer->aSubTimers[0].NtDpc, (int)pTimer->idCpu);
+            rc = rtMpNtSetTargetProcessorDpc(&pTimer->aSubTimers[0].NtDpc, (int)pTimer->idCpu);
+    }
+    if (RT_SUCCESS(rc))
+    {
+        *ppTimer = pTimer;
+        return VINF_SUCCESS;
     }
 
-    *ppTimer = pTimer;
-    return VINF_SUCCESS;
+    RTMemFree(pTimer);
+    return rc;
 }
 
 
diff --git a/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def b/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def
new file mode 100644
index 0000000..92e186e
--- /dev/null
+++ b/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def
@@ -0,0 +1,214 @@
+; $Id: VBoxRT-openssl-1.1plus.def $
+;; @file
+; IPRT - Windows OpenSSL exports we use outside VBoxRT (keep them few!).
+;
+; This file is appended to the architecture specific .def file.
+;
+
+;
+; Copyright (C) 2009-2016 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+    ; ConsoleImpl.cpp uses this when VBOX_OPENSSL_FIPS is enabled.
+    FIPS_mode
+
+    ; VBoxVRDP.dll - secure.cpp
+    BIO_free
+    BIO_new_file
+    BN_bin2bn
+    BN_bn2bin
+    BN_CTX_free
+    BN_CTX_new
+    BN_free
+    BN_mod_exp
+    BN_new
+    BN_num_bits
+    BN_set_word
+    EVP_PKEY_get0_RSA
+    i2d_X509
+    MD5_Final
+    MD5_Init
+    MD5_Update
+    OBJ_obj2nid
+    PEM_read_bio_PrivateKey
+    PEM_read_bio_X509
+    RAND_bytes
+    RC4
+    RC4_set_key
+    RSA_free
+    RSA_generate_key_ex
+    RSA_get0_key
+    RSA_new
+    SHA1_Final
+    SHA1_Init
+    SHA1_Update
+    X509_free
+    X509_get_X509_PUBKEY
+    X509_PUBKEY_get0_param
+
+    ; VBoxVRDP.dll - tcp_vrdp.cpp
+    BIO_new_socket
+    BIO_test_flags
+    OPENSSL_init_ssl
+    SSL_accept
+    SSL_CTX_free
+    SSL_CTX_load_verify_locations
+    SSL_CTX_new
+    SSL_CTX_set_verify
+    SSL_CTX_use_certificate_file
+    SSL_CTX_use_PrivateKey_file
+    SSL_free
+    SSL_get_certificate
+    SSL_new
+    SSL_pending
+    SSL_read
+    SSL_set_bio
+    SSL_set_read_ahead
+    SSL_write
+    TLSv1_server_method
+    X509_get_issuer_name
+    X509_NAME_oneline
+
+    ; VDPluginCrypt.dll (if it wanted to use IPRT) - VDKeyStore.cpp:
+    EVP_aes_128_xts
+    EVP_aes_256_xts
+    EVP_CIPHER_CTX_free
+    EVP_CIPHER_CTX_new
+    EVP_DecryptFinal
+    EVP_DecryptInit
+    EVP_DecryptUpdate
+    EVP_EncryptFinal
+    EVP_EncryptInit
+    EVP_EncryptUpdate
+    EVP_MD_size
+    EVP_sha1
+    EVP_sha256
+    EVP_sha512
+    PKCS5_PBKDF2_HMAC
+    ;exported above: RAND_bytes
+
+    ; VDPluginCrypt.dll (if it wanted to use IPRT) - VDFilterCrypt.cpp:
+    ;exported above: EVP_aes_128_xts
+    ;exported above: EVP_aes_256_xts
+    ;exported above: EVP_CIPHER_CTX_free
+    ;exported above: EVP_CIPHER_CTX_new
+    ;exported above: EVP_DecryptFinal
+    ;exported above: EVP_DecryptInit
+    ;exported above: EVP_DecryptUpdate
+    ;exported above: EVP_EncryptFinal
+    ;exported above: EVP_EncryptInit
+    ;exported above: EVP_EncryptUpdate
+    ;exported above: RAND_bytes
+
+    ; vboxwebsrv needs SSL support.
+    ASN1_STRING_data
+    ASN1_STRING_to_UTF8
+    ;exported above: BIO_free
+    ;exported above: BIO_new_file
+    ;exported above: BIO_new_socket
+    BIO_read
+    BIO_write
+    CRYPTO_free
+    DH_check
+    DH_free
+    DH_generate_parameters
+    ERR_clear_error
+    ERR_error_string
+    ERR_error_string_n
+    ERR_get_error
+    ERR_peek_error
+    GENERAL_NAME_free
+    i2v_GENERAL_NAMES
+    OPENSSL_init_crypto
+    ;exported above: OPENSSL_init_ssl
+    OPENSSL_sk_num
+    OPENSSL_sk_pop_free
+    OPENSSL_sk_value
+    PEM_read_bio_DHparams
+    RAND_load_file
+    RAND_pseudo_bytes
+    RAND_seed
+    RAND_status
+    ;exported above: RSA_free
+    RSA_generate_key
+    ;exported above: SSL_accept
+    SSL_clear
+    SSL_connect
+    SSL_ctrl
+    SSL_CTX_ctrl
+    ;exported above: SSL_CTX_free
+    SSL_CTX_get_cert_store
+    ;exported above: SSL_CTX_load_verify_locations
+    ;exported above: SSL_CTX_new
+    SSL_CTX_set_client_CA_list
+    SSL_CTX_set_default_passwd_cb
+    SSL_CTX_set_default_passwd_cb_userdata
+    SSL_CTX_set_default_verify_paths
+    SSL_CTX_set_options
+    SSL_CTX_set_session_id_context
+    ;exported above: SSL_CTX_set_verify
+    SSL_CTX_set_verify_depth
+    SSL_CTX_use_certificate_chain_file
+    ;exported above: SSL_CTX_use_PrivateKey_file
+    ;exported above: SSL_free
+    SSL_get_error
+    SSL_get_peer_certificate
+    SSL_get_verify_result
+    SSL_get1_session
+    SSL_is_init_finished
+    SSL_load_client_CA_file
+    ;exported above: SSL_new
+    SSL_peek
+    ;exported above: SSL_read
+    SSL_SESSION_free
+    ;exported above: SSL_set_bio
+    SSL_set_session
+    SSL_shutdown
+    SSL_want
+    ;exported above: SSL_write
+    TLS_method
+    ;exported above: X509_free
+    X509_get_ext_d2i
+    ;exported above: X509_get_issuer_name
+    X509_get_subject_name
+    X509_load_crl_file
+    X509_LOOKUP_file
+    X509_NAME_ENTRY_get_data
+    X509_NAME_get_entry
+    X509_NAME_get_index_by_NID
+    ;exported above: X509_NAME_oneline
+    X509_STORE_add_lookup
+    X509_STORE_CTX_get_current_cert
+    X509_STORE_CTX_get_error
+    X509_STORE_CTX_get_error_depth
+    X509_STORE_CTX_set_error
+    X509_STORE_set1_param
+    X509_verify_cert_error_string
+    X509_VERIFY_PARAM_free
+    X509_VERIFY_PARAM_new
+    X509_VERIFY_PARAM_set_flags
+    X509V3_conf_free
+
+    ; tstRTBigNum.cpp
+    BN_div
+    BN_mul
+    BN_mod_exp_simple
+    BN_ucmp
+
diff --git a/src/VBox/Runtime/r3/win/VBoxRT-openssl-ose.def b/src/VBox/Runtime/r3/win/VBoxRT-openssl-ose.def
deleted file mode 100644
index a10f837..0000000
--- a/src/VBox/Runtime/r3/win/VBoxRT-openssl-ose.def
+++ /dev/null
@@ -1,1707 +0,0 @@
-; $Id: VBoxRT-openssl-ose.def $
-;; @file
-; IPRT - Windows OpenSSL exports.
-;
-; This file is appended to the architecture specific .def file.
-;
-; E:\coding\vbox\svn\trunk\tools\win.x86\vcc\v8sp1\bin\x86_amd64\dumpbin.exe \coding\vbox\svn\trunk\out\win.amd64\debug\lib\VBox-libcrypto.lib /symbols /OUT:foo.lst
-; grep " External " foo.lst | grep -v " UNDEF " | grep -v " ??_" | grep -v " notype  " | sort   | cut -d "|" -f 2
-;
-
-;
-; Copyright (C) 2009-2016 Oracle Corporation
-;
-; This file is part of VirtualBox Open Source Edition (OSE), as
-; available from http://www.virtualbox.org. This file is free software;
-; you can redistribute it and/or modify it under the terms of the GNU
-; General Public License (GPL) as published by the Free Software
-; Foundation, in version 2 as it comes in the "COPYING" file of the
-; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-;
-; The contents of this file may alternatively be used under the terms
-; of the Common Development and Distribution License Version 1.0
-; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
-; VirtualBox OSE distribution, in which case the provisions of the
-; CDDL are applicable instead of those of the GPL.
-;
-; You may elect to license modified versions of this file under the
-; terms and conditions of either the GPL or the CDDL or both.
-;
-
-    ;
-    ; OpenSSL symbols
-    ;
-;;    _CONF_get_section
-;;    _CONF_get_string
-    a2d_ASN1_OBJECT
-    a2i_ASN1_INTEGER
-    a2i_ASN1_STRING
-    a2i_ipadd
-    a2i_IPADDRESS
-    a2i_IPADDRESS_NC
-    ACCESS_DESCRIPTION_free
-    ACCESS_DESCRIPTION_new
-    asn1_add_error
-    ASN1_BIT_STRING_free
-    ASN1_BIT_STRING_get_bit
-    ASN1_BIT_STRING_new
-    ASN1_BIT_STRING_set
-    ASN1_BIT_STRING_set_bit
-    ASN1_BMPSTRING_free
-    ASN1_BMPSTRING_new
-    ASN1_check_infinite_end
-    ASN1_const_check_infinite_end
-    asn1_const_Finish
-    ASN1_d2i_bio
-    ASN1_d2i_fp
-    ASN1_digest
-    asn1_do_adb
-    asn1_do_lock
-    ASN1_dup
-    asn1_enc_free
-    asn1_enc_init
-    asn1_enc_restore
-    asn1_enc_save
-    ASN1_ENUMERATED_free
-    ASN1_ENUMERATED_get
-    ASN1_ENUMERATED_new
-    ASN1_ENUMERATED_set
-    ASN1_ENUMERATED_to_BN
-    asn1_ex_c2i
-    asn1_ex_i2c
-    asn1_Finish
-    ASN1_GENERALIZEDTIME_check
-    ASN1_GENERALIZEDTIME_free
-    ASN1_GENERALIZEDTIME_new
-    ASN1_GENERALIZEDTIME_print
-    ASN1_GENERALIZEDTIME_set
-    ASN1_GENERALIZEDTIME_set_string
-    ASN1_GENERALSTRING_free
-    ASN1_GENERALSTRING_new
-    ASN1_generate_nconf
-    ASN1_generate_v3
-    asn1_get_choice_selector
-    asn1_get_field_ptr
-    ASN1_get_object
-    asn1_GetSequence
-    ASN1_i2d_bio
-    ASN1_i2d_fp
-    ASN1_IA5STRING_free
-    ASN1_IA5STRING_new
-    ASN1_INTEGER_cmp
-    ASN1_INTEGER_dup
-    ASN1_INTEGER_free
-    ASN1_INTEGER_get
-    ASN1_INTEGER_new
-    ASN1_INTEGER_set
-    ASN1_INTEGER_to_BN
-    ASN1_item_d2i
-    ASN1_item_d2i_bio
-    ASN1_item_d2i_fp
-    ASN1_item_digest
-    ASN1_item_dup
-    ASN1_item_ex_d2i
-    ASN1_item_ex_free
-    ASN1_item_ex_i2d
-    ASN1_item_ex_new
-    ASN1_item_free
-    ASN1_item_i2d
-    ASN1_item_i2d_bio
-    ASN1_item_i2d_fp
-    ASN1_item_ndef_i2d
-    ASN1_item_new
-    ASN1_item_pack
-    ASN1_item_sign
-    ASN1_item_unpack
-    ASN1_item_verify
-    ASN1_mbstring_copy
-    ASN1_mbstring_ncopy
-    ASN1_NULL_free
-    ASN1_NULL_new
-    ASN1_OBJECT_create
-    ASN1_OBJECT_free
-    ASN1_OBJECT_new
-    ASN1_object_size
-    ASN1_OCTET_STRING_cmp
-    ASN1_OCTET_STRING_dup
-    ASN1_OCTET_STRING_free
-    ASN1_OCTET_STRING_new
-    ASN1_OCTET_STRING_set
-    ASN1_pack_string
-    ASN1_parse
-    ASN1_parse_dump
-    ASN1_primitive_free
-    ASN1_primitive_new
-    ASN1_PRINTABLE_free
-    ASN1_PRINTABLE_new
-    ASN1_PRINTABLE_type
-    ASN1_PRINTABLESTRING_free
-    ASN1_PRINTABLESTRING_new
-    ASN1_put_eoc
-    ASN1_put_object
-    ASN1_seq_pack
-    ASN1_seq_unpack
-    asn1_set_choice_selector
-    ASN1_sign
-    ASN1_STRING_cmp
-    ASN1_STRING_data
-    ASN1_STRING_dup
-    ASN1_STRING_free
-    ASN1_STRING_get_default_mask
-    ASN1_STRING_length
-    ASN1_STRING_length_set
-    ASN1_STRING_new
-    ASN1_STRING_print
-    ASN1_STRING_print_ex
-    ASN1_STRING_print_ex_fp
-    ASN1_STRING_set
-    ASN1_STRING_set0
-    ASN1_STRING_set_by_NID
-    ASN1_STRING_set_default_mask
-    ASN1_STRING_set_default_mask_asc
-    ASN1_STRING_TABLE_add
-    ASN1_STRING_TABLE_cleanup
-    ASN1_STRING_TABLE_get
-    ASN1_STRING_to_UTF8
-    ASN1_STRING_type
-    ASN1_STRING_type_new
-    ASN1_T61STRING_free
-    ASN1_T61STRING_new
-    ASN1_tag2bit
-    ASN1_tag2str
-    ASN1_template_d2i
-    ASN1_template_free
-    ASN1_template_i2d
-    ASN1_template_new
-    ASN1_TIME_check
-    ASN1_TIME_free
-    ASN1_TIME_new
-    ASN1_TIME_print
-    ASN1_TIME_set
-    ASN1_TIME_to_generalizedtime
-    ASN1_TYPE_free
-    ASN1_TYPE_get
-    ASN1_TYPE_get_int_octetstring
-    ASN1_TYPE_get_octetstring
-    ASN1_TYPE_new
-    ASN1_TYPE_set
-    ASN1_TYPE_set1
-    ASN1_TYPE_set_int_octetstring
-    ASN1_TYPE_set_octetstring
-    ASN1_UNIVERSALSTRING_free
-    ASN1_UNIVERSALSTRING_new
-    ASN1_UNIVERSALSTRING_to_string
-    ASN1_unpack_string
-    ASN1_UTCTIME_check
-    ASN1_UTCTIME_cmp_time_t
-    ASN1_UTCTIME_free
-    ASN1_UTCTIME_new
-    ASN1_UTCTIME_print
-    ASN1_UTCTIME_set
-    ASN1_UTCTIME_set_string
-    ASN1_UTF8STRING_free
-    ASN1_UTF8STRING_new
-    ASN1_verify
-    ASN1_VISIBLESTRING_free
-    ASN1_VISIBLESTRING_new
-    AUTHORITY_INFO_ACCESS_free
-    AUTHORITY_INFO_ACCESS_new
-    AUTHORITY_KEYID_free
-    AUTHORITY_KEYID_new
-    BASIC_CONSTRAINTS_free
-    BASIC_CONSTRAINTS_new
-    BIO_callback_ctrl
-    BIO_clear_flags
-    BIO_copy_next_retry
-    BIO_ctrl
-    BIO_ctrl_pending
-    BIO_ctrl_wpending
-    BIO_dump
-    BIO_dump_cb
-    BIO_dump_fp
-    BIO_dump_indent
-    BIO_dump_indent_cb
-    BIO_dump_indent_fp
-    BIO_dup_chain
-    BIO_f_buffer
-    BIO_find_type
-    BIO_free
-    BIO_free_all
-    BIO_get_callback
-    BIO_get_callback_arg
-    BIO_get_ex_data
-    BIO_get_ex_new_index
-    BIO_get_retry_BIO
-    BIO_get_retry_reason
-    BIO_gets
-    BIO_indent
-    BIO_int_ctrl
-    BIO_method_name
-    BIO_method_type
-    BIO_new
-    BIO_new_file
-    BIO_new_fp
-    BIO_new_socket
-    BIO_next
-    BIO_number_read
-    BIO_number_written
-    BIO_pop
-    BIO_ptr_ctrl
-    BIO_push
-    BIO_puts
-    BIO_read
-    BIO_s_file
-    BIO_s_socket
-    BIO_set
-    BIO_set_callback
-    BIO_set_callback_arg
-    BIO_set_ex_data
-    BIO_set_flags
-    BIO_test_flags
-    BIO_vfree
-    BIO_write
-    BN_add
-    BN_add_word
-    bn_add_words
-    BN_bin2bn
-    BN_BLINDING_convert
-    BN_BLINDING_convert_ex
-    BN_BLINDING_create_param
-    BN_BLINDING_free
-    BN_BLINDING_get_flags
-    BN_BLINDING_get_thread_id
-    BN_BLINDING_invert
-    BN_BLINDING_invert_ex
-    BN_BLINDING_new
-    BN_BLINDING_set_flags
-    BN_BLINDING_set_thread_id
-    BN_BLINDING_update
-    BN_bn2bin
-    BN_bn2dec
-    BN_bn2hex
-    BN_bntest_rand
-    BN_clear
-    BN_clear_bit
-    BN_clear_free
-    BN_cmp
-    BN_copy
-    BN_CTX_end
-    BN_CTX_free
-    BN_CTX_get
-    BN_CTX_init
-    BN_CTX_new
-    BN_CTX_start
-    BN_dec2bn
-    BN_div
-    BN_div_recp
-    BN_div_word
-    bn_div_words
-    BN_dup
-    bn_dup_expand
-    BN_exp
-    bn_expand2
-    BN_free
-    BN_from_montgomery
-    BN_gcd
-    BN_GENCB_call
-    BN_generate_prime_ex
-    BN_get0_nist_prime_192
-    BN_get0_nist_prime_224
-    BN_get0_nist_prime_256
-    BN_get0_nist_prime_384
-    BN_get0_nist_prime_521
-    BN_get_params
-    BN_get_word
-    BN_GF2m_add
-    BN_GF2m_arr2poly
-    BN_GF2m_mod
-    BN_GF2m_mod_arr
-    BN_GF2m_mod_div
-    BN_GF2m_mod_div_arr
-    BN_GF2m_mod_exp
-    BN_GF2m_mod_exp_arr
-    BN_GF2m_mod_inv
-    BN_GF2m_mod_inv_arr
-    BN_GF2m_mod_mul
-    BN_GF2m_mod_mul_arr
-    BN_GF2m_mod_solve_quad
-    BN_GF2m_mod_solve_quad_arr
-    BN_GF2m_mod_sqr
-    BN_GF2m_mod_sqr_arr
-    BN_GF2m_mod_sqrt
-    BN_GF2m_mod_sqrt_arr
-    BN_GF2m_poly2arr
-    BN_hex2bn
-    BN_init
-    BN_is_bit_set
-    BN_is_prime_ex
-    BN_is_prime_fasttest_ex
-    BN_kronecker
-    BN_lshift
-    BN_lshift1
-    BN_mask_bits
-    BN_mod_add
-    BN_mod_add_quick
-    BN_mod_exp
-    BN_mod_exp_mont
-    BN_mod_exp_mont_consttime
-    BN_mod_exp_mont_word
-    BN_mod_exp_recp
-    BN_mod_exp_simple
-    BN_mod_inverse
-    BN_mod_lshift
-    BN_mod_lshift1
-    BN_mod_lshift1_quick
-    BN_mod_lshift_quick
-    BN_mod_mul
-    BN_mod_mul_montgomery
-    BN_mod_mul_reciprocal
-    BN_mod_sqr
-    BN_mod_sqrt
-    BN_mod_sub
-    BN_mod_sub_quick
-    BN_mod_word
-    BN_MONT_CTX_copy
-    BN_MONT_CTX_free
-    BN_MONT_CTX_init
-    BN_MONT_CTX_new
-    BN_MONT_CTX_set
-    BN_MONT_CTX_set_locked
-    BN_mul
-    bn_mul_add_words
-    BN_mul_word
-    bn_mul_words
-    BN_new
-    BN_nist_mod_192
-    BN_nist_mod_224
-    BN_nist_mod_256
-    BN_nist_mod_384
-    BN_nist_mod_521
-    BN_nnmod
-    BN_num_bits
-    BN_num_bits_word
-    BN_print
-    BN_pseudo_rand
-    BN_pseudo_rand_range
-    BN_rand
-    BN_rand_range
-    BN_reciprocal
-    BN_RECP_CTX_free
-    BN_RECP_CTX_init
-    BN_RECP_CTX_new
-    BN_RECP_CTX_set
-    BN_rshift
-    BN_rshift1
-    BN_set_bit
-    BN_set_negative
-    BN_set_params
-    BN_set_word
-    BN_sqr
-    bn_sqr_words
-    BN_sub
-    BN_sub_word
-    bn_sub_words
-    BN_swap
-    BN_to_ASN1_ENUMERATED
-    BN_to_ASN1_INTEGER
-    BN_uadd
-    BN_ucmp
-    BN_usub
-    BN_value_one
-    BUF_MEM_free
-    BUF_MEM_grow
-    BUF_MEM_grow_clean
-    BUF_MEM_new
-    BUF_memdup
-    BUF_strdup
-    BUF_strlcat
-    BUF_strlcpy
-    BUF_strndup
-    c2i_ASN1_BIT_STRING
-    c2i_ASN1_INTEGER
-    c2i_ASN1_OBJECT
-    CERTIFICATEPOLICIES_free
-    CERTIFICATEPOLICIES_new
-    CONF_dump_bio
-    CONF_dump_fp
-    CONF_free
-    CONF_get_number
-    CONF_get_section
-    CONF_get_string
-    CONF_load
-    CONF_load_bio
-    CONF_load_fp
-    CONF_parse_list
-    CONF_set_default_method
-    CONF_set_nconf
-    CRL_DIST_POINTS_free
-    CRL_DIST_POINTS_new
-    CRYPTO_add_lock
-    CRYPTO_cleanup_all_ex_data
-    CRYPTO_dbg_free
-    CRYPTO_dbg_get_options
-    CRYPTO_dbg_malloc
-;;    CRYPTO_dbg_pop_info
-;;    CRYPTO_dbg_push_info
-    CRYPTO_dbg_realloc
-;;    CRYPTO_dbg_remove_all_info
-    CRYPTO_dbg_set_options
-    CRYPTO_destroy_dynlockid
-    CRYPTO_dup_ex_data
-    CRYPTO_ex_data_new_class
-    CRYPTO_free
-    CRYPTO_free_ex_data
-    CRYPTO_free_locked
-    CRYPTO_get_add_lock_callback
-    CRYPTO_get_dynlock_create_callback
-    CRYPTO_get_dynlock_destroy_callback
-    CRYPTO_get_dynlock_lock_callback
-    CRYPTO_get_dynlock_value
-    CRYPTO_get_ex_data
-    CRYPTO_get_ex_data_implementation
-    CRYPTO_get_ex_new_index
-    CRYPTO_get_id_callback
-    CRYPTO_get_locked_mem_ex_functions
-    CRYPTO_get_locked_mem_functions
-    CRYPTO_get_locking_callback
-    CRYPTO_get_mem_debug_functions
-    CRYPTO_get_mem_debug_options
-    CRYPTO_get_mem_ex_functions
-    CRYPTO_get_mem_functions
-    CRYPTO_get_new_dynlockid
-    CRYPTO_get_new_lockid
-    CRYPTO_is_mem_check_on
-    CRYPTO_lock
-    CRYPTO_malloc
-;;    CRYPTO_malloc_debug_init
-    CRYPTO_malloc_locked
-    CRYPTO_mem_ctrl
-    CRYPTO_mem_leaks
-    CRYPTO_mem_leaks_cb
-    CRYPTO_mem_leaks_fp
-    CRYPTO_new_ex_data
-    CRYPTO_num_locks
-    CRYPTO_pop_info
-    CRYPTO_push_info_
-    CRYPTO_realloc
-    CRYPTO_realloc_clean
-    CRYPTO_remalloc
-    CRYPTO_remove_all_info
-    CRYPTO_set_add_lock_callback
-    CRYPTO_set_dynlock_create_callback
-    CRYPTO_set_dynlock_destroy_callback
-    CRYPTO_set_dynlock_lock_callback
-    CRYPTO_set_ex_data
-    CRYPTO_set_ex_data_implementation
-    CRYPTO_set_id_callback
-    CRYPTO_set_locked_mem_ex_functions
-    CRYPTO_set_locked_mem_functions
-    CRYPTO_set_locking_callback
-    CRYPTO_set_mem_debug_functions
-    CRYPTO_set_mem_debug_options
-    CRYPTO_set_mem_ex_functions
-    CRYPTO_set_mem_functions
-;;    CRYPTO_set_mem_info_functions
-    CRYPTO_strdup
-    CRYPTO_thread_id
-    d2i_ACCESS_DESCRIPTION
-    d2i_ASN1_BIT_STRING
-    d2i_ASN1_BMPSTRING
-    d2i_ASN1_BOOLEAN
-    d2i_ASN1_bytes
-    d2i_ASN1_ENUMERATED
-    d2i_ASN1_GENERALIZEDTIME
-    d2i_ASN1_GENERALSTRING
-    d2i_ASN1_IA5STRING
-    d2i_ASN1_INTEGER
-    d2i_ASN1_NULL
-    d2i_ASN1_OBJECT
-    d2i_ASN1_OCTET_STRING
-    d2i_ASN1_PRINTABLE
-    d2i_ASN1_PRINTABLESTRING
-    d2i_ASN1_SET
-    d2i_ASN1_T61STRING
-    d2i_ASN1_TIME
-    d2i_ASN1_TYPE
-    d2i_ASN1_type_bytes
-    d2i_ASN1_UINTEGER
-    d2i_ASN1_UNIVERSALSTRING
-    d2i_ASN1_UTCTIME
-    d2i_ASN1_UTF8STRING
-    d2i_ASN1_VISIBLESTRING
-    d2i_AUTHORITY_INFO_ACCESS
-    d2i_AUTHORITY_KEYID
-    d2i_AutoPrivateKey
-    d2i_BASIC_CONSTRAINTS
-    d2i_CERTIFICATEPOLICIES
-    d2i_CRL_DIST_POINTS
-    d2i_DHparams
-    d2i_DIRECTORYSTRING
-    d2i_DISPLAYTEXT
-    d2i_DIST_POINT
-    d2i_DIST_POINT_NAME
-    d2i_EC_PUBKEY
-    d2i_EC_PUBKEY_bio
-    d2i_ECDSA_SIG
-    d2i_ECParameters
-    d2i_ECPKParameters
-    d2i_ECPrivateKey
-    d2i_ECPrivateKey_bio
-    d2i_EDIPARTYNAME
-    d2i_EXTENDED_KEY_USAGE
-    d2i_GENERAL_NAME
-    d2i_GENERAL_NAMES
-    d2i_NETSCAPE_SPKAC
-    d2i_NETSCAPE_SPKI
-    d2i_NOTICEREF
-    d2i_OCSP_BASICRESP
-    d2i_OCSP_CERTID
-    d2i_OCSP_CERTSTATUS
-    d2i_OCSP_CRLID
-    d2i_OCSP_ONEREQ
-    d2i_OCSP_REQINFO
-    d2i_OCSP_REQUEST
-    d2i_OCSP_RESPBYTES
-    d2i_OCSP_RESPDATA
-    d2i_OCSP_RESPID
-    d2i_OCSP_RESPONSE
-    d2i_OCSP_REVOKEDINFO
-    d2i_OCSP_SERVICELOC
-    d2i_OCSP_SIGNATURE
-    d2i_OCSP_SINGLERESP
-    d2i_OTHERNAME
-    d2i_PKCS7
-    d2i_PKCS7_bio
-    d2i_PKCS7_DIGEST
-    d2i_PKCS7_ENC_CONTENT
-    d2i_PKCS7_ENCRYPT
-    d2i_PKCS7_ENVELOPE
-    d2i_PKCS7_ISSUER_AND_SERIAL
-    d2i_PKCS7_RECIP_INFO
-    d2i_PKCS7_SIGN_ENVELOPE
-    d2i_PKCS7_SIGNED
-    d2i_PKCS7_SIGNER_INFO
-    d2i_PKCS8_bio
-    d2i_PKCS8_PRIV_KEY_INFO
-    d2i_PKCS8_PRIV_KEY_INFO_bio
-    d2i_PKEY_USAGE_PERIOD
-    d2i_POLICYINFO
-    d2i_POLICYQUALINFO
-    d2i_PrivateKey
-    d2i_PrivateKey_bio
-    d2i_PROXY_CERT_INFO_EXTENSION
-    d2i_PROXY_POLICY
-    d2i_PUBKEY
-    d2i_PUBKEY_bio
-    d2i_PublicKey
-    d2i_RSA_PUBKEY
-    d2i_RSA_PUBKEY_bio
-    d2i_RSAPrivateKey
-    d2i_RSAPrivateKey_bio
-    d2i_RSAPublicKey
-    d2i_RSAPublicKey_bio
-    d2i_SXNET
-    d2i_SXNETID
-    d2i_USERNOTICE
-    d2i_X509
-    d2i_X509_ALGOR
-    d2i_X509_ALGORS
-    d2i_X509_ATTRIBUTE
-    d2i_X509_AUX
-    d2i_X509_bio
-    d2i_X509_CERT_AUX
-    d2i_X509_CERT_PAIR
-    d2i_X509_CINF
-    d2i_X509_CRL
-    d2i_X509_CRL_bio
-    d2i_X509_CRL_INFO
-    d2i_X509_EXTENSION
-    d2i_X509_EXTENSIONS
-    d2i_X509_NAME
-    d2i_X509_NAME_ENTRY
-    d2i_X509_PUBKEY
-    d2i_X509_REQ
-    d2i_X509_REQ_bio
-    d2i_X509_REQ_INFO
-    d2i_X509_REVOKED
-    d2i_X509_SIG
-    d2i_X509_VAL
-    DH_check
-    DH_check_pub_key
-    DH_compute_key
-    DH_free
-    DH_generate_key
-    DH_get_default_method
-    DH_get_ex_data
-    DH_get_ex_new_index
-    DH_new
-    DH_new_method
-    DH_OpenSSL
-    DH_set_default_method
-    DH_set_ex_data
-    DH_set_method
-    DH_size
-    DH_up_ref
-    DHparams_print
-    DHparams_print_fp
-    DIRECTORYSTRING_free
-    DIRECTORYSTRING_new
-    DISPLAYTEXT_free
-    DISPLAYTEXT_new
-    DIST_POINT_free
-    DIST_POINT_NAME_free
-    DIST_POINT_NAME_new
-    DIST_POINT_new
-    EC_get_builtin_curves
-    EC_GF2m_simple_method
-    EC_GFp_mont_method
-    EC_GFp_nist_method
-    EC_GFp_simple_method
-    EC_GROUP_check_discriminant
-    EC_GROUP_clear_free
-    EC_GROUP_cmp
-    EC_GROUP_copy
-    EC_GROUP_dup
-    EC_GROUP_free
-    EC_GROUP_get0_generator
-    EC_GROUP_get0_seed
-    EC_GROUP_get_asn1_flag
-    EC_GROUP_get_basis_type
-    EC_GROUP_get_cofactor
-    EC_GROUP_get_curve_GF2m
-    EC_GROUP_get_curve_GFp
-    EC_GROUP_get_curve_name
-    EC_GROUP_get_degree
-    EC_GROUP_get_order
-    EC_GROUP_get_pentanomial_basis
-    EC_GROUP_get_point_conversion_form
-    EC_GROUP_get_seed_len
-    EC_GROUP_get_trinomial_basis
-    EC_GROUP_have_precompute_mult
-    EC_GROUP_method_of
-    EC_GROUP_new
-    EC_GROUP_new_by_curve_name
-    EC_GROUP_new_curve_GF2m
-    EC_GROUP_new_curve_GFp
-    EC_GROUP_precompute_mult
-    EC_GROUP_set_asn1_flag
-    EC_GROUP_set_curve_GF2m
-    EC_GROUP_set_curve_GFp
-    EC_GROUP_set_curve_name
-    EC_GROUP_set_generator
-    EC_GROUP_set_point_conversion_form
-    EC_GROUP_set_seed
-    EC_KEY_check_key
-    EC_KEY_copy
-    EC_KEY_dup
-    EC_KEY_free
-    EC_KEY_generate_key
-    EC_KEY_get0_group
-    EC_KEY_get0_private_key
-    EC_KEY_get0_public_key
-    EC_KEY_get_conv_form
-    EC_KEY_get_enc_flags
-    EC_KEY_get_key_method_data
-    EC_KEY_insert_key_method_data
-    EC_KEY_new
-    EC_KEY_new_by_curve_name
-    EC_KEY_precompute_mult
-    EC_KEY_print
-    EC_KEY_print_fp
-    EC_KEY_set_asn1_flag
-    EC_KEY_set_conv_form
-    EC_KEY_set_enc_flags
-    EC_KEY_set_group
-    EC_KEY_set_private_key
-    EC_KEY_set_public_key
-    EC_KEY_up_ref
-    EC_METHOD_get_field_type
-    EC_POINT_add
-    EC_POINT_bn2point
-    EC_POINT_clear_free
-    EC_POINT_cmp
-    EC_POINT_copy
-    EC_POINT_dbl
-    EC_POINT_dup
-    EC_POINT_free
-    EC_POINT_get_affine_coordinates_GF2m
-    EC_POINT_get_affine_coordinates_GFp
-    EC_POINT_get_Jprojective_coordinates_GFp
-    EC_POINT_hex2point
-    EC_POINT_invert
-    EC_POINT_is_at_infinity
-    EC_POINT_is_on_curve
-    EC_POINT_make_affine
-    EC_POINT_method_of
-    EC_POINT_mul
-    EC_POINT_new
-    EC_POINT_oct2point
-    EC_POINT_point2bn
-    EC_POINT_point2hex
-    EC_POINT_point2oct
-    EC_POINT_set_affine_coordinates_GF2m
-    EC_POINT_set_affine_coordinates_GFp
-    EC_POINT_set_compressed_coordinates_GF2m
-    EC_POINT_set_compressed_coordinates_GFp
-    EC_POINT_set_Jprojective_coordinates_GFp
-    EC_POINT_set_to_infinity
-    EC_POINTs_make_affine
-    EC_POINTs_mul
-    ECDSA_do_sign
-    ECDSA_do_sign_ex
-    ECDSA_get_default_method
-    ECDSA_get_ex_data
-    ECDSA_get_ex_new_index
-    ECDSA_OpenSSL
-    ECDSA_set_default_method
-    ECDSA_set_ex_data
-    ECDSA_set_method
-    ECDSA_SIG_free
-    ECDSA_SIG_new
-    ECDSA_sign
-    ECDSA_sign_ex
-    ECDSA_sign_setup
-    ECDSA_size
-    ECDSA_verify
-    ECParameters_print
-    ECParameters_print_fp
-    ECPKParameters_print
-    ECPKParameters_print_fp
-    EDIPARTYNAME_free
-    EDIPARTYNAME_new
-    ERR_add_error_data
-    ERR_clear_error
-    ERR_error_string
-    ERR_error_string_n
-    ERR_free_strings
-    ERR_func_error_string
-    ERR_get_err_state_table
-    ERR_get_error
-    ERR_get_error_line
-    ERR_get_error_line_data
-    ERR_get_implementation
-    ERR_get_next_error_library
-    ERR_get_state
-    ERR_get_string_table
-    ERR_lib_error_string
-    ERR_load_ERR_strings
-    ERR_load_strings
-    ERR_peek_error
-    ERR_peek_error_line
-    ERR_peek_error_line_data
-    ERR_peek_last_error
-    ERR_peek_last_error_line
-    ERR_peek_last_error_line_data
-    ERR_print_errors
-    ERR_print_errors_cb
-    ERR_put_error
-    ERR_reason_error_string
-    ERR_release_err_state_table
-    ERR_remove_state
-    ERR_set_error_data
-    ERR_set_implementation
-    ERR_unload_strings
-    EVP_add_cipher
-    EVP_add_digest
-    EVP_aes_128_cbc
-    EVP_aes_128_xts
-    EVP_aes_192_cbc
-    EVP_aes_256_cbc
-    EVP_aes_256_xts
-    EVP_BytesToKey
-    EVP_Cipher
-    EVP_CIPHER_asn1_to_param
-    EVP_CIPHER_block_size
-    EVP_CIPHER_CTX_block_size
-    EVP_CIPHER_CTX_cipher
-    EVP_CIPHER_CTX_cleanup
-    EVP_CIPHER_CTX_clear_flags
-    EVP_CIPHER_CTX_ctrl
-    EVP_CIPHER_CTX_flags
-    EVP_CIPHER_CTX_free
-    EVP_CIPHER_CTX_get_app_data
-    EVP_CIPHER_CTX_init
-    EVP_CIPHER_CTX_iv_length
-    EVP_CIPHER_CTX_key_length
-    EVP_CIPHER_CTX_new
-    EVP_CIPHER_CTX_nid
-    EVP_CIPHER_CTX_rand_key
-    EVP_CIPHER_CTX_set_app_data
-    EVP_CIPHER_CTX_set_flags
-    EVP_CIPHER_CTX_set_key_length
-    EVP_CIPHER_CTX_set_padding
-    EVP_CIPHER_CTX_test_flags
-    EVP_CIPHER_flags
-    EVP_CIPHER_get_asn1_iv
-    EVP_CIPHER_iv_length
-    EVP_CIPHER_key_length
-    EVP_CIPHER_nid
-    EVP_CIPHER_param_to_asn1
-    EVP_CIPHER_set_asn1_iv
-    EVP_CIPHER_type
-    EVP_CipherFinal
-    EVP_CipherFinal_ex
-    EVP_CipherInit
-    EVP_CipherInit_ex
-    EVP_CipherUpdate
-    EVP_cleanup
-    EVP_DecodeBlock
-    EVP_DecodeFinal
-    EVP_DecodeInit
-    EVP_DecodeUpdate
-    EVP_DecryptFinal
-    EVP_DecryptFinal_ex
-    EVP_DecryptInit
-    EVP_DecryptInit_ex
-    EVP_DecryptUpdate
-    EVP_Digest
-    EVP_DigestFinal
-    EVP_DigestFinal_ex
-    EVP_DigestInit
-    EVP_DigestInit_ex
-    EVP_DigestUpdate
-    EVP_ecdsa
-    EVP_enc_null
-    EVP_EncodeBlock
-    EVP_EncodeFinal
-    EVP_EncodeInit
-    EVP_EncodeUpdate
-    EVP_EncryptFinal
-    EVP_EncryptFinal_ex
-    EVP_EncryptInit
-    EVP_EncryptInit_ex
-    EVP_EncryptUpdate
-    EVP_get_cipherbyname
-    EVP_get_digestbyname
-    EVP_get_pw_prompt
-    EVP_md5
-    EVP_MD_block_size
-    EVP_MD_CTX_cleanup
-    EVP_MD_CTX_clear_flags
-    EVP_MD_CTX_copy
-    EVP_MD_CTX_copy_ex
-    EVP_MD_CTX_create
-    EVP_MD_CTX_destroy
-    EVP_MD_CTX_init
-    EVP_MD_CTX_md
-    EVP_MD_CTX_set_flags
-    EVP_MD_CTX_test_flags
-    EVP_MD_pkey_type
-    EVP_MD_size
-    EVP_MD_type
-    EVP_PBE_alg_add
-    EVP_PBE_CipherInit
-    EVP_PBE_cleanup
-    EVP_PKCS82PKEY
-    EVP_PKEY2PKCS8
-    EVP_PKEY2PKCS8_broken
-    EVP_PKEY_add1_attr
-    EVP_PKEY_add1_attr_by_NID
-    EVP_PKEY_add1_attr_by_OBJ
-    EVP_PKEY_add1_attr_by_txt
-    EVP_PKEY_assign
-    EVP_PKEY_bits
-    EVP_PKEY_cmp
-    EVP_PKEY_cmp_parameters
-    EVP_PKEY_copy_parameters
-    EVP_PKEY_delete_attr
-    EVP_PKEY_free
-    EVP_PKEY_get1_DH
-    EVP_PKEY_get1_EC_KEY
-    EVP_PKEY_get1_RSA
-    EVP_PKEY_get_attr
-    EVP_PKEY_get_attr_by_NID
-    EVP_PKEY_get_attr_by_OBJ
-    EVP_PKEY_get_attr_count
-    EVP_PKEY_missing_parameters
-    EVP_PKEY_new
-    EVP_PKEY_save_parameters
-    EVP_PKEY_set1_DH
-    EVP_PKEY_set1_EC_KEY
-    EVP_PKEY_set1_RSA
-    EVP_PKEY_size
-    EVP_PKEY_type
-    EVP_rc4
-    EVP_read_pw_string
-    EVP_set_pw_prompt
-    EVP_sha1
-    EVP_sha224
-    EVP_sha256
-    EVP_sha384
-    EVP_sha512
-    EVP_SignFinal
-    EVP_VerifyFinal
-    EXTENDED_KEY_USAGE_free
-    EXTENDED_KEY_USAGE_new
-    GENERAL_NAME_free
-    GENERAL_NAME_new
-    GENERAL_NAME_print
-    GENERAL_NAMES_free
-    GENERAL_NAMES_new
-    GENERAL_SUBTREE_free
-    GENERAL_SUBTREE_new
-    hex_to_string
-    HMAC
-    HMAC_CTX_cleanup
-    HMAC_CTX_init
-    HMAC_CTX_set_flags
-    HMAC_Final
-    HMAC_Init
-    HMAC_Init_ex
-    HMAC_Update
-    i2a_ACCESS_DESCRIPTION
-    i2a_ASN1_INTEGER
-    i2a_ASN1_OBJECT
-    i2a_ASN1_STRING
-    i2c_ASN1_BIT_STRING
-    i2c_ASN1_INTEGER
-    i2d_ACCESS_DESCRIPTION
-    i2d_ASN1_BIT_STRING
-    i2d_ASN1_BMPSTRING
-    i2d_ASN1_BOOLEAN
-    i2d_ASN1_bytes
-    i2d_ASN1_ENUMERATED
-    i2d_ASN1_GENERALIZEDTIME
-    i2d_ASN1_GENERALSTRING
-    i2d_ASN1_IA5STRING
-    i2d_ASN1_INTEGER
-    i2d_ASN1_NULL
-    i2d_ASN1_OBJECT
-    i2d_ASN1_OCTET_STRING
-    i2d_ASN1_PRINTABLE
-    i2d_ASN1_PRINTABLESTRING
-    i2d_ASN1_SET
-    i2d_ASN1_T61STRING
-    i2d_ASN1_TIME
-    i2d_ASN1_TYPE
-    i2d_ASN1_UNIVERSALSTRING
-    i2d_ASN1_UTCTIME
-    i2d_ASN1_UTF8STRING
-    i2d_ASN1_VISIBLESTRING
-    i2d_AUTHORITY_INFO_ACCESS
-    i2d_AUTHORITY_KEYID
-    i2d_BASIC_CONSTRAINTS
-    i2d_CERTIFICATEPOLICIES
-    i2d_CRL_DIST_POINTS
-    i2d_DHparams
-    i2d_DIRECTORYSTRING
-    i2d_DISPLAYTEXT
-    i2d_DIST_POINT
-    i2d_DIST_POINT_NAME
-    i2d_EC_PUBKEY
-    i2d_EC_PUBKEY_bio
-    i2d_ECDSA_SIG
-    i2d_ECParameters
-    i2d_ECPKParameters
-    i2d_ECPrivateKey
-    i2d_ECPrivateKey_bio
-    i2d_EDIPARTYNAME
-    i2d_EXTENDED_KEY_USAGE
-    i2d_GENERAL_NAME
-    i2d_GENERAL_NAMES
-    i2d_NETSCAPE_SPKAC
-    i2d_NETSCAPE_SPKI
-    i2d_NOTICEREF
-    i2d_OCSP_BASICRESP
-    i2d_OCSP_CERTID
-    i2d_OCSP_CERTSTATUS
-    i2d_OCSP_CRLID
-    i2d_OCSP_ONEREQ
-    i2d_OCSP_REQINFO
-    i2d_OCSP_REQUEST
-    i2d_OCSP_RESPBYTES
-    i2d_OCSP_RESPDATA
-    i2d_OCSP_RESPID
-    i2d_OCSP_RESPONSE
-    i2d_OCSP_REVOKEDINFO
-    i2d_OCSP_SERVICELOC
-    i2d_OCSP_SIGNATURE
-    i2d_OCSP_SINGLERESP
-    i2d_OTHERNAME
-    i2d_PKCS7
-    i2d_PKCS7_bio
-    i2d_PKCS7_DIGEST
-    i2d_PKCS7_ENC_CONTENT
-    i2d_PKCS7_ENCRYPT
-    i2d_PKCS7_ENVELOPE
-    i2d_PKCS7_ISSUER_AND_SERIAL
-    i2d_PKCS7_NDEF
-    i2d_PKCS7_RECIP_INFO
-    i2d_PKCS7_SIGN_ENVELOPE
-    i2d_PKCS7_SIGNED
-    i2d_PKCS7_SIGNER_INFO
-    i2d_PKCS8_bio
-    i2d_PKCS8_PRIV_KEY_INFO
-    i2d_PKCS8_PRIV_KEY_INFO_bio
-    i2d_PKCS8PrivateKeyInfo_bio
-    i2d_PKEY_USAGE_PERIOD
-    i2d_POLICYINFO
-    i2d_POLICYQUALINFO
-    i2d_PrivateKey
-    i2d_PrivateKey_bio
-    i2d_PROXY_CERT_INFO_EXTENSION
-    i2d_PROXY_POLICY
-    i2d_PUBKEY
-    i2d_PUBKEY_bio
-    i2d_PublicKey
-    i2d_RSA_PUBKEY
-    i2d_RSA_PUBKEY_bio
-    i2d_RSAPrivateKey
-    i2d_RSAPrivateKey_bio
-    i2d_RSAPublicKey
-    i2d_RSAPublicKey_bio
-    i2d_SXNET
-    i2d_SXNETID
-    i2d_USERNOTICE
-    i2d_X509
-    i2d_X509_ALGOR
-    i2d_X509_ALGORS
-    i2d_X509_ATTRIBUTE
-    i2d_X509_AUX
-    i2d_X509_bio
-    i2d_X509_CERT_AUX
-    i2d_X509_CERT_PAIR
-    i2d_X509_CINF
-    i2d_X509_CRL
-    i2d_X509_CRL_bio
-    i2d_X509_CRL_INFO
-    i2d_X509_EXTENSION
-    i2d_X509_EXTENSIONS
-    i2d_X509_NAME
-    i2d_X509_NAME_ENTRY
-    i2d_X509_PUBKEY
-    i2d_X509_REQ
-    i2d_X509_REQ_bio
-    i2d_X509_REQ_INFO
-    i2d_X509_REVOKED
-    i2d_X509_SIG
-    i2d_X509_VAL
-    i2o_ECPublicKey
-    i2s_ASN1_ENUMERATED
-    i2s_ASN1_ENUMERATED_TABLE
-    i2s_ASN1_INTEGER
-    i2s_ASN1_OCTET_STRING
-    i2t_ASN1_OBJECT
-    i2v_ASN1_BIT_STRING
-    i2v_GENERAL_NAME
-    i2v_GENERAL_NAMES
-    lh_delete
-    lh_doall
-    lh_doall_arg
-    lh_free
-    lh_insert
-    lh_new
-    lh_num_items
-    lh_retrieve
-    lh_strhash
-    MD5_Final
-    MD5_Init
-    MD5_Transform
-    MD5_Update
-    name_cmp
-    NAME_CONSTRAINTS_free
-    NAME_CONSTRAINTS_new
-    NCONF_default
-    NCONF_dump_bio
-    NCONF_dump_fp
-    NCONF_free
-    NCONF_free_data
-    NCONF_get_number_e
-    NCONF_get_section
-    NCONF_get_string
-    NCONF_load
-    NCONF_load_bio
-    NCONF_load_fp
-    NCONF_new
-    NCONF_WIN32
-    NETSCAPE_SPKAC_free
-    NETSCAPE_SPKAC_new
-    NETSCAPE_SPKI_free
-    NETSCAPE_SPKI_new
-    NETSCAPE_SPKI_sign
-    NETSCAPE_SPKI_verify
-    NOTICEREF_free
-    NOTICEREF_new
-    o2i_ECPublicKey
-    OBJ_add_object
-;;    OBJ_bsearch
-;;    OBJ_bsearch_ex
-    OBJ_cleanup
-    OBJ_cmp
-    OBJ_create
-    OBJ_create_objects
-    OBJ_dup
-    OBJ_ln2nid
-    OBJ_NAME_add
-    OBJ_NAME_cleanup
-    OBJ_NAME_do_all
-    OBJ_NAME_do_all_sorted
-    OBJ_NAME_get
-    OBJ_NAME_init
-    OBJ_NAME_new_index
-    OBJ_NAME_remove
-    OBJ_new_nid
-    OBJ_nid2ln
-    OBJ_nid2obj
-    OBJ_nid2sn
-    OBJ_obj2nid
-    OBJ_obj2txt
-    OBJ_sn2nid
-    OBJ_txt2nid
-    OBJ_txt2obj
-    OCSP_BASICRESP_free
-    OCSP_BASICRESP_new
-    OCSP_CERTID_free
-    OCSP_CERTID_new
-    OCSP_CERTSTATUS_free
-    OCSP_CERTSTATUS_new
-    OCSP_CRLID_free
-    OCSP_CRLID_new
-    OCSP_ONEREQ_free
-    OCSP_ONEREQ_new
-    OCSP_REQINFO_free
-    OCSP_REQINFO_new
-    OCSP_REQUEST_free
-    OCSP_REQUEST_new
-    OCSP_RESPBYTES_free
-    OCSP_RESPBYTES_new
-    OCSP_RESPDATA_free
-    OCSP_RESPDATA_new
-    OCSP_RESPID_free
-    OCSP_RESPID_new
-    OCSP_RESPONSE_free
-    OCSP_RESPONSE_new
-    OCSP_REVOKEDINFO_free
-    OCSP_REVOKEDINFO_new
-    OCSP_SERVICELOC_free
-    OCSP_SERVICELOC_new
-    OCSP_SIGNATURE_free
-    OCSP_SIGNATURE_new
-    OCSP_SINGLERESP_free
-    OCSP_SINGLERESP_new
-    OPENSSL_cleanse
-    OPENSSL_isservice
-    OpenSSLDie
-    OTHERNAME_free
-    OTHERNAME_new
-    PEM_ASN1_read_bio
-    PEM_ASN1_write_bio
-    PEM_bytes_read_bio
-    PEM_def_callback
-    PEM_dek_info
-    PEM_do_header
-    PEM_get_EVP_CIPHER_INFO
-    PEM_proc_type
-    PEM_read_bio
-    PEM_read_bio_PrivateKey
-    PEM_read_bio_RSAPrivateKey
-    PEM_read_bio_X509
-    PEM_read_bio_X509_AUX
-    PEM_write_bio
-    PEM_write_bio_X509
-    PKCS7_DIGEST_free
-    PKCS7_DIGEST_new
-    PKCS7_dup
-    PKCS7_ENC_CONTENT_free
-    PKCS7_ENC_CONTENT_new
-    PKCS7_ENCRYPT_free
-    PKCS7_ENCRYPT_new
-    PKCS7_ENVELOPE_free
-    PKCS7_ENVELOPE_new
-    PKCS7_free
-    PKCS7_ISSUER_AND_SERIAL_digest
-    PKCS7_ISSUER_AND_SERIAL_free
-    PKCS7_ISSUER_AND_SERIAL_new
-    PKCS7_new
-    PKCS7_RECIP_INFO_free
-    PKCS7_RECIP_INFO_new
-    PKCS7_SIGN_ENVELOPE_free
-    PKCS7_SIGN_ENVELOPE_new
-    PKCS7_SIGNED_free
-    PKCS7_SIGNED_new
-    PKCS7_SIGNER_INFO_free
-    PKCS7_SIGNER_INFO_new
-    PKCS8_PRIV_KEY_INFO_free
-    PKCS8_PRIV_KEY_INFO_new
-    PKCS8_set_broken
-    PKEY_USAGE_PERIOD_free
-    PKEY_USAGE_PERIOD_new
-    POLICY_CONSTRAINTS_free
-    POLICY_CONSTRAINTS_new
-    POLICY_MAPPING_free
-    POLICY_MAPPING_new
-    POLICYINFO_free
-    POLICYINFO_new
-    POLICYQUALINFO_free
-    POLICYQUALINFO_new
-    PROXY_CERT_INFO_EXTENSION_free
-    PROXY_CERT_INFO_EXTENSION_new
-    PROXY_POLICY_free
-    PROXY_POLICY_new
-    RAND_add
-    RAND_bytes
-    RAND_cleanup
-    RAND_egd
-    RAND_egd_bytes
-    RAND_event
-    RAND_get_rand_method
-    RAND_poll
-    RAND_pseudo_bytes
-    RAND_query_egd_bytes
-    RAND_screen
-    RAND_seed
-    RAND_set_rand_method
-    RAND_SSLeay
-    RAND_status
-    RC4
-    RC4_options
-    RC4_set_key
-    RSA_blinding_off
-    RSA_blinding_on
-    RSA_flags
-    RSA_free
-    RSA_generate_key
-    RSA_generate_key_ex
-    RSA_get_default_method
-    RSA_get_ex_data
-    RSA_get_ex_new_index
-    RSA_get_method
-    RSA_memory_lock
-    RSA_new
-    RSA_new_method
-    RSA_null_method
-    RSA_print
-    RSA_print_fp
-    RSA_private_decrypt
-    RSA_private_encrypt
-    RSA_public_decrypt
-    RSA_public_encrypt
-    RSA_set_default_method
-    RSA_set_ex_data
-    RSA_set_method
-    RSA_setup_blinding
-    RSA_sign
-    RSA_size
-    RSA_up_ref
-    RSA_verify
-;;    RSAPrivateKey_asn1_meth
-    RSAPrivateKey_dup
-    RSAPublicKey_dup
-    s2i_ASN1_INTEGER
-    s2i_ASN1_OCTET_STRING
-    SHA1_Final
-    SHA1_Init
-    SHA1_Transform
-    SHA1_Update
-    SHA224
-    SHA224_Final
-    SHA224_Init
-    SHA224_Update
-    SHA256
-    SHA256_Final
-    SHA256_Init
-    SHA256_Transform
-    SHA256_Update
-    SHA384
-    SHA384_Final
-    SHA384_Init
-    SHA384_Update
-    SHA512
-    SHA512_Final
-    SHA512_Init
-    SHA512_Transform
-    SHA512_Update
-    sk_delete
-    sk_delete_ptr
-    sk_dup
-    sk_find
-    sk_find_ex
-    sk_free
-    sk_insert
-    sk_is_sorted
-    sk_new
-    sk_new_null
-    sk_num
-    sk_pop
-    sk_pop_free
-    sk_push
-    sk_set
-    sk_set_cmp_func
-    sk_shift
-    sk_sort
-    sk_unshift
-    sk_value
-    sk_zero
-    SSLeay
-    SSLeay_version
-    SSL_accept
-    SSL_CTX_free
-    SSL_CTX_load_verify_locations
-    SSL_CTX_new
-    SSL_CTX_set_verify
-    SSL_CTX_use_certificate_file
-    SSL_CTX_use_PrivateKey_file
-    SSL_free
-    SSL_get_certificate
-    SSL_library_init
-    SSL_new
-    SSL_pending
-    SSL_read
-    SSL_set_bio
-    SSL_set_read_ahead
-    SSL_write
-    string_to_hex
-    SXNET_add_id_asc
-    SXNET_add_id_INTEGER
-    SXNET_add_id_ulong
-    SXNET_free
-    SXNET_get_id_asc
-    SXNET_get_id_INTEGER
-    SXNET_get_id_ulong
-    SXNET_new
-    SXNETID_free
-    SXNETID_new
-    TLSv1_server_method
-    UI_add_error_string
-    UI_add_info_string
-    UI_add_input_boolean
-    UI_add_input_string
-    UI_add_user_data
-    UI_add_verify_string
-    UI_construct_prompt
-    UI_create_method
-    UI_ctrl
-    UI_destroy_method
-    UI_dup_error_string
-    UI_dup_info_string
-    UI_dup_input_boolean
-    UI_dup_input_string
-    UI_dup_verify_string
-    UI_free
-    UI_get0_action_string
-    UI_get0_output_string
-    UI_get0_result
-    UI_get0_result_string
-    UI_get0_test_string
-    UI_get0_user_data
-    UI_get_default_method
-    UI_get_ex_data
-    UI_get_ex_new_index
-    UI_get_input_flags
-    UI_get_method
-    UI_get_result_maxsize
-    UI_get_result_minsize
-    UI_get_string_type
-    UI_method_get_closer
-    UI_method_get_flusher
-    UI_method_get_opener
-    UI_method_get_reader
-    UI_method_get_writer
-    UI_method_set_closer
-    UI_method_set_flusher
-    UI_method_set_opener
-    UI_method_set_reader
-    UI_method_set_writer
-    UI_new
-    UI_new_method
-    UI_OpenSSL
-    UI_process
-    UI_set_default_method
-    UI_set_ex_data
-    UI_set_method
-    UI_set_result
-    USERNOTICE_free
-    USERNOTICE_new
-    UTF8_getc
-    UTF8_putc
-    v2i_ASN1_BIT_STRING
-    v2i_GENERAL_NAME
-    v2i_GENERAL_NAME_ex
-    v2i_GENERAL_NAMES
-    X509_add1_ext_i2d
-    X509_add1_reject_object
-    X509_add1_trust_object
-    X509_add_ext
-    X509_ALGOR_dup
-    X509_ALGOR_free
-    X509_ALGOR_get0
-    X509_ALGOR_new
-    X509_ALGOR_set0
-    X509_alias_get0
-    X509_alias_set1
-;;    X509_asn1_meth
-    X509_ATTRIBUTE_count
-    X509_ATTRIBUTE_create
-    X509_ATTRIBUTE_create_by_NID
-    X509_ATTRIBUTE_create_by_OBJ
-    X509_ATTRIBUTE_create_by_txt
-    X509_ATTRIBUTE_dup
-    X509_ATTRIBUTE_free
-    X509_ATTRIBUTE_get0_data
-    X509_ATTRIBUTE_get0_object
-    X509_ATTRIBUTE_get0_type
-    X509_ATTRIBUTE_new
-    X509_ATTRIBUTE_set1_data
-    X509_ATTRIBUTE_set1_object
-    X509_CERT_AUX_free
-    X509_CERT_AUX_new
-    X509_CERT_AUX_print
-    X509_CERT_PAIR_free
-    X509_CERT_PAIR_new
-    X509_certificate_type
-    X509_check_ca
-    X509_check_issued
-    X509_check_private_key
-    X509_check_purpose
-    X509_CINF_free
-    X509_CINF_new
-    X509_cmp
-    X509_CRL_add0_revoked
-    X509_CRL_add1_ext_i2d
-    X509_CRL_add_ext
-    X509_CRL_cmp
-    X509_CRL_delete_ext
-    X509_CRL_digest
-    X509_CRL_dup
-    X509_CRL_free
-    X509_CRL_get_ext
-    X509_CRL_get_ext_by_critical
-    X509_CRL_get_ext_by_NID
-    X509_CRL_get_ext_by_OBJ
-    X509_CRL_get_ext_count
-    X509_CRL_get_ext_d2i
-    X509_CRL_INFO_free
-    X509_CRL_INFO_new
-    X509_CRL_new
-    X509_CRL_sign
-    X509_CRL_verify
-    X509_delete_ext
-    X509_digest
-    X509_dup
-    X509_email_free
-    X509_EXTENSION_create_by_NID
-    X509_EXTENSION_create_by_OBJ
-    X509_EXTENSION_dup
-    X509_EXTENSION_free
-    X509_EXTENSION_get_critical
-    X509_EXTENSION_get_data
-    X509_EXTENSION_get_object
-    X509_EXTENSION_new
-    X509_EXTENSION_set_critical
-    X509_EXTENSION_set_data
-    X509_EXTENSION_set_object
-    X509_find_by_issuer_and_serial
-    X509_find_by_subject
-    X509_free
-    X509_get0_pubkey_bitstr
-    X509_get1_email
-    X509_get1_ocsp
-    X509_get_ex_data
-    X509_get_ex_new_index
-    X509_get_ext
-    X509_get_ext_by_critical
-    X509_get_ext_by_NID
-    X509_get_ext_by_OBJ
-    X509_get_ext_count
-    X509_get_ext_d2i
-    X509_get_issuer_name
-    X509_get_pubkey
-    X509_get_serialNumber
-    X509_get_subject_name
-    X509_issuer_and_serial_cmp
-    X509_issuer_and_serial_hash
-    X509_issuer_name_cmp
-    X509_issuer_name_hash
-    X509_keyid_get0
-    X509_keyid_set1
-    X509_NAME_add_entry
-    X509_NAME_add_entry_by_NID
-    X509_NAME_add_entry_by_OBJ
-    X509_NAME_add_entry_by_txt
-    X509_NAME_cmp
-    X509_NAME_delete_entry
-    X509_NAME_digest
-    X509_NAME_dup
-    X509_NAME_entry_count
-    X509_NAME_ENTRY_create_by_NID
-    X509_NAME_ENTRY_create_by_OBJ
-    X509_NAME_ENTRY_create_by_txt
-    X509_NAME_ENTRY_dup
-    X509_NAME_ENTRY_free
-    X509_NAME_ENTRY_get_data
-    X509_NAME_ENTRY_get_object
-    X509_NAME_ENTRY_new
-    X509_NAME_ENTRY_set_data
-    X509_NAME_ENTRY_set_object
-    X509_NAME_free
-    X509_NAME_get_entry
-    X509_NAME_get_index_by_NID
-    X509_NAME_get_index_by_OBJ
-    X509_NAME_get_text_by_NID
-    X509_NAME_get_text_by_OBJ
-    X509_NAME_hash
-    X509_NAME_new
-    X509_NAME_oneline
-    X509_NAME_print
-    X509_NAME_print_ex
-    X509_NAME_print_ex_fp
-    X509_NAME_set
-    X509_new
-    X509_ocspid_print
-    X509_POLICY_NODE_print
-    X509_print
-    X509_print_ex
-    X509_print_ex_fp
-    X509_print_fp
-    X509_pubkey_digest
-    X509_PUBKEY_free
-    X509_PUBKEY_get
-    X509_PUBKEY_new
-    X509_PUBKEY_set
-    X509_PURPOSE_add
-    X509_PURPOSE_cleanup
-    X509_PURPOSE_get0
-    X509_PURPOSE_get0_name
-    X509_PURPOSE_get0_sname
-    X509_PURPOSE_get_by_id
-    X509_PURPOSE_get_by_sname
-    X509_PURPOSE_get_count
-    X509_PURPOSE_get_id
-    X509_PURPOSE_get_trust
-    X509_PURPOSE_set
-    X509_reject_clear
-    X509_REQ_add1_attr
-    X509_REQ_add1_attr_by_NID
-    X509_REQ_add1_attr_by_OBJ
-    X509_REQ_add1_attr_by_txt
-    X509_REQ_add_extensions
-    X509_REQ_add_extensions_nid
-    X509_REQ_check_private_key
-    X509_REQ_delete_attr
-    X509_REQ_digest
-    X509_REQ_dup
-    X509_REQ_extension_nid
-    X509_REQ_free
-    X509_REQ_get1_email
-    X509_REQ_get_attr
-    X509_REQ_get_attr_by_NID
-    X509_REQ_get_attr_by_OBJ
-    X509_REQ_get_attr_count
-    X509_REQ_get_extension_nids
-    X509_REQ_get_extensions
-    X509_REQ_get_pubkey
-    X509_REQ_INFO_free
-    X509_REQ_INFO_new
-    X509_REQ_new
-    X509_REQ_set_extension_nids
-    X509_REQ_set_pubkey
-    X509_REQ_set_subject_name
-    X509_REQ_set_version
-    X509_REQ_sign
-    X509_REQ_verify
-    X509_REVOKED_add1_ext_i2d
-    X509_REVOKED_add_ext
-    X509_REVOKED_delete_ext
-    X509_REVOKED_free
-    X509_REVOKED_get_ext
-    X509_REVOKED_get_ext_by_critical
-    X509_REVOKED_get_ext_by_NID
-    X509_REVOKED_get_ext_by_OBJ
-    X509_REVOKED_get_ext_count
-    X509_REVOKED_get_ext_d2i
-    X509_REVOKED_new
-    X509_set_ex_data
-    X509_SIG_free
-    X509_SIG_new
-    X509_sign
-    X509_signature_print
-    X509_STORE_CTX_cleanup
-    X509_STORE_CTX_get_ex_new_index
-    X509_STORE_CTX_get0_param
-    X509_STORE_CTX_init
-    X509_STORE_CTX_set_default
-    X509_STORE_CTX_set_ex_data
-    X509_STORE_CTX_set_verify_cb
-    X509_STORE_free
-    X509_STORE_load_locations
-    X509_STORE_new
-    X509_STORE_set_default_paths
-    X509_subject_name_cmp
-    X509_subject_name_hash
-    X509_supported_extension
-    X509_to_X509_REQ
-    X509_trust_clear
-    X509_VAL_free
-    X509_VAL_new
-    X509_verify
-    X509_verify_cert
-    X509_VERIFY_PARAM_free
-    X509_VERIFY_PARAM_get_depth
-    X509_VERIFY_PARAM_inherit
-    X509_VERIFY_PARAM_new
-    X509_VERIFY_PARAM_set_depth
-    X509_VERIFY_PARAM_set_purpose
-    X509_VERIFY_PARAM_set_trust
-    X509_VERIFY_PARAM_set1
-    X509at_add1_attr
-    X509at_add1_attr_by_NID
-    X509at_add1_attr_by_OBJ
-    X509at_add1_attr_by_txt
-    X509at_delete_attr
-    X509at_get0_data_by_OBJ
-    X509at_get_attr
-    X509at_get_attr_by_NID
-    X509at_get_attr_by_OBJ
-    X509at_get_attr_count
-    X509V3_add1_i2d
-    X509v3_add_ext
-    X509V3_add_standard_extensions
-    X509V3_add_value
-    X509V3_add_value_bool
-    X509V3_add_value_bool_nf
-    X509V3_add_value_int
-    X509V3_add_value_uchar
-    X509V3_conf_free
-    X509v3_delete_ext
-    X509V3_EXT_add
-    X509V3_EXT_add_alias
-    X509V3_EXT_add_conf
-    X509V3_EXT_add_list
-    X509V3_EXT_add_nconf
-    X509V3_EXT_add_nconf_sk
-    X509V3_EXT_cleanup
-    X509V3_EXT_conf
-    X509V3_EXT_conf_nid
-    X509V3_EXT_CRL_add_conf
-    X509V3_EXT_CRL_add_nconf
-    X509V3_EXT_d2i
-    X509V3_EXT_get
-    X509V3_EXT_get_nid
-    X509V3_EXT_i2d
-    X509V3_EXT_nconf
-    X509V3_EXT_nconf_nid
-    X509V3_EXT_print
-    X509V3_EXT_print_fp
-    X509V3_EXT_REQ_add_conf
-    X509V3_EXT_REQ_add_nconf
-    X509V3_EXT_val_prn
-    X509V3_extensions_print
-    X509V3_get_d2i
-    X509v3_get_ext
-    X509v3_get_ext_by_critical
-    X509v3_get_ext_by_NID
-    X509v3_get_ext_by_OBJ
-    X509v3_get_ext_count
-    X509V3_get_section
-    X509V3_get_string
-    X509V3_get_value_bool
-    X509V3_get_value_int
-    X509V3_NAME_from_section
-    X509V3_parse_list
-    X509V3_section_free
-    X509V3_set_conf_lhash
-    X509V3_set_ctx
-    X509V3_set_nconf
-    X509V3_string_free
-
diff --git a/src/VBox/Runtime/r3/win/VBoxRT-openssl-pre-1.1.def b/src/VBox/Runtime/r3/win/VBoxRT-openssl-pre-1.1.def
new file mode 100644
index 0000000..8754e37
--- /dev/null
+++ b/src/VBox/Runtime/r3/win/VBoxRT-openssl-pre-1.1.def
@@ -0,0 +1,242 @@
+; $Id: VBoxRT-openssl-pre-1.1.def $
+;; @file
+; IPRT - Windows OpenSSL v1.0.x exports we use outside VBoxRT (keep them few!).
+;
+; This file is appended to the architecture specific .def file.
+;
+
+;
+; Copyright (C) 2009-2016 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+    ; ConsoleImpl.cpp uses this when VBOX_OPENSSL_FIPS is enabled.
+    FIPS_mode
+
+    ; VBoxVRDP.dll - secure.cpp
+    BIO_free
+    BIO_new_file
+    BN_bin2bn
+    BN_bn2bin
+    BN_CTX_free
+    BN_CTX_new
+    BN_free
+    BN_mod_exp
+    BN_new
+    BN_num_bits
+    BN_set_word
+    ;1.1.0: EVP_PKEY_get0_RSA
+    i2d_X509
+    MD5_Final
+    MD5_Init
+    MD5_Update
+    OBJ_obj2nid
+    PEM_read_bio_PrivateKey
+    PEM_read_bio_X509
+    RAND_bytes
+    RC4
+    RC4_set_key
+    RSA_free
+    RSA_generate_key_ex
+    ;1.1.0: RSA_get0_key
+    RSA_new
+    SHA1_Final
+    SHA1_Init
+    SHA1_Update
+    X509_free
+    ;1.1.0: X509_get_X509_PUBKEY
+    X509_PUBKEY_get0_param
+
+    ; VBoxVRDP.dll - secure.cpp - 1.0.1 additions:
+    BN_init
+
+    ; VBoxVRDP.dll - tcp_vrdp.cpp
+    BIO_new_socket
+    BIO_test_flags
+    ;1.1.0: OPENSSL_init_ssl
+    SSL_accept
+    SSL_CTX_free
+    SSL_CTX_load_verify_locations
+    SSL_CTX_new
+    SSL_CTX_set_verify
+    SSL_CTX_use_certificate_file
+    SSL_CTX_use_PrivateKey_file
+    SSL_free
+    SSL_get_certificate
+    SSL_new
+    SSL_pending
+    SSL_read
+    SSL_set_bio
+    SSL_set_read_ahead
+    SSL_write
+    TLSv1_server_method
+    X509_get_issuer_name
+    X509_NAME_oneline
+
+    ; VDPluginCrypt.dll (if it wanted to use IPRT) - VDKeyStore.cpp:
+    EVP_aes_128_xts
+    EVP_aes_256_xts
+    EVP_CIPHER_CTX_free
+    EVP_CIPHER_CTX_new
+    EVP_DecryptFinal
+    EVP_DecryptInit
+    EVP_DecryptUpdate
+    EVP_EncryptFinal
+    EVP_EncryptInit
+    EVP_EncryptUpdate
+    EVP_MD_size
+    EVP_sha1
+    EVP_sha256
+    EVP_sha512
+    PKCS5_PBKDF2_HMAC
+    ;exported above: RAND_bytes
+
+    ; VDPluginCrypt.dll (if it wanted to use IPRT) - VDFilterCrypt.cpp:
+    ;exported above: EVP_aes_128_xts
+    ;exported above: EVP_aes_256_xts
+    ;exported above: EVP_CIPHER_CTX_free
+    ;exported above: EVP_CIPHER_CTX_new
+    ;exported above: EVP_DecryptFinal
+    ;exported above: EVP_DecryptInit
+    ;exported above: EVP_DecryptUpdate
+    ;exported above: EVP_EncryptFinal
+    ;exported above: EVP_EncryptInit
+    ;exported above: EVP_EncryptUpdate
+    ;exported above: RAND_bytes
+
+    ; vboxwebsrv needs SSL support.
+    ASN1_STRING_data
+    ASN1_STRING_to_UTF8
+    ;exported above: BIO_free
+    ;exported above: BIO_new_file
+    ;exported above: BIO_new_socket
+    BIO_read
+    BIO_write
+    CRYPTO_free
+    DH_check
+    DH_free
+    DH_generate_parameters
+    ERR_clear_error
+    ERR_error_string
+    ERR_error_string_n
+    ERR_get_error
+    ERR_peek_error
+    GENERAL_NAME_free
+    i2v_GENERAL_NAMES
+    ;1.1.0: OPENSSL_init_crypto
+    ;exported above: OPENSSL_init_ssl
+    ;1.1.0: OPENSSL_sk_num
+    ;1.1.0: OPENSSL_sk_pop_free
+    ;1.1.0: OPENSSL_sk_value
+    PEM_read_bio_DHparams
+    RAND_load_file
+    RAND_pseudo_bytes
+    RAND_seed
+    RAND_status
+    ;exported above: RSA_free
+    RSA_generate_key
+    ;exported above: SSL_accept
+    SSL_clear
+    SSL_connect
+    SSL_ctrl
+    SSL_CTX_ctrl
+    ;exported above: SSL_CTX_free
+    SSL_CTX_get_cert_store
+    ;exported above: SSL_CTX_load_verify_locations
+    ;exported above: SSL_CTX_new
+    SSL_CTX_set_client_CA_list
+    SSL_CTX_set_default_passwd_cb
+    SSL_CTX_set_default_passwd_cb_userdata
+    SSL_CTX_set_default_verify_paths
+    ;1.1.0: SSL_CTX_set_options
+    SSL_CTX_set_session_id_context
+    ;exported above: SSL_CTX_set_verify
+    SSL_CTX_set_verify_depth
+    SSL_CTX_use_certificate_chain_file
+    ;exported above: SSL_CTX_use_PrivateKey_file
+    ;exported above: SSL_free
+    SSL_get_error
+    SSL_get_peer_certificate
+    SSL_get_verify_result
+    SSL_get1_session
+    ;1.1.0: SSL_is_init_finished
+    SSL_load_client_CA_file
+    ;exported above: SSL_new
+    SSL_peek
+    ;exported above: SSL_read
+    SSL_SESSION_free
+    ;exported above: SSL_set_bio
+    SSL_set_session
+    SSL_shutdown
+    SSL_want
+    ;exported above: SSL_write
+    ;1.1.0: TLS_method
+    ;exported above: X509_free
+    X509_get_ext_d2i
+    ;exported above: X509_get_issuer_name
+    X509_get_subject_name
+    X509_load_crl_file
+    X509_LOOKUP_file
+    X509_NAME_ENTRY_get_data
+    X509_NAME_get_entry
+    X509_NAME_get_index_by_NID
+    ;exported above: X509_NAME_oneline
+    X509_STORE_add_lookup
+    X509_STORE_CTX_get_current_cert
+    X509_STORE_CTX_get_error
+    X509_STORE_CTX_get_error_depth
+    X509_STORE_CTX_set_error
+    X509_STORE_set1_param
+    X509_verify_cert_error_string
+    X509_VERIFY_PARAM_free
+    X509_VERIFY_PARAM_new
+    X509_VERIFY_PARAM_set_flags
+    X509V3_conf_free
+
+    ; vboxwebsrv - 1.0.1 additions
+    CRYPTO_set_dynlock_destroy_callback
+    CRYPTO_set_dynlock_lock_callback
+    CRYPTO_set_dynlock_create_callback
+    CRYPTO_set_locking_callback
+    CRYPTO_set_id_callback
+    CRYPTO_num_locks
+    ERR_remove_state
+    OPENSSL_add_all_algorithms_noconf
+    sk_value
+    sk_num
+    sk_pop_free
+    SSL_load_error_strings
+    SSL_library_init
+    SSL_state
+    SSLv23_method
+
+    ; vboxwebsrv - 1.0.1 additions for older gsoap version.
+    ASN1_item_d2i
+    OBJ_nid2sn
+    X509_EXTENSION_get_object
+    X509_get_ext
+    X509_get_ext_count
+    X509V3_EXT_get
+
+    ; tstRTBigNum.cpp
+    BN_div
+    BN_mul
+    BN_mod_exp_simple
+    BN_ucmp
+
diff --git a/src/VBox/Runtime/r3/win/VBoxRT-openssl.def b/src/VBox/Runtime/r3/win/VBoxRT-openssl.def
deleted file mode 100644
index 86ed1be..0000000
--- a/src/VBox/Runtime/r3/win/VBoxRT-openssl.def
+++ /dev/null
@@ -1,3253 +0,0 @@
-; $Id: VBoxRT-openssl.def 109093 2016-07-22 19:30:22Z bird $
-;; @file
-; IPRT - Windows OpenSSL exports.
-;
-; This file is appended to the architecture specific .def file.
-;
-; E:\coding\vbox\svn\trunk\tools\win.x86\vcc\v10sp1\bin\dumpbin.exe \coding\vbox\svn\trunk\out\win.amd64\debug\lib\VBox-libcrypto.lib /symbols /out:foo.lst
-; grep " External " foo.lst | grep -v " UNDEF " | grep -v " ??_" | grep -v " notype  " | cut -d "|" -f 2 | sort
-;
-
-;
-; Copyright (C) 2009-2016 Oracle Corporation
-;
-; This file is part of VirtualBox Open Source Edition (OSE), as
-; available from http://www.virtualbox.org. This file is free software;
-; you can redistribute it and/or modify it under the terms of the GNU
-; General Public License (GPL) as published by the Free Software
-; Foundation, in version 2 as it comes in the "COPYING" file of the
-; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-;
-; The contents of this file may alternatively be used under the terms
-; of the Common Development and Distribution License Version 1.0
-; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
-; VirtualBox OSE distribution, in which case the provisions of the
-; CDDL are applicable instead of those of the GPL.
-;
-; You may elect to license modified versions of this file under the
-; terms and conditions of either the GPL or the CDDL or both.
-;
-
-    ;
-    ; OpenSSL crypto symbols
-    ;
-    _CONF_add_string
-    _CONF_free_data
-    _CONF_get_section
-    _CONF_get_section_values
-    _CONF_get_string
-    _CONF_new_data
-    _CONF_new_section
-    a2d_ASN1_OBJECT
-    a2i_ASN1_ENUMERATED
-    a2i_ASN1_INTEGER
-    a2i_ASN1_STRING
-    a2i_GENERAL_NAME
-    a2i_ipadd
-    a2i_IPADDRESS
-    a2i_IPADDRESS_NC
-    ACCESS_DESCRIPTION_free
-    ACCESS_DESCRIPTION_new
-    AES_bi_ige_encrypt
-    AES_cbc_encrypt
-    AES_cfb1_encrypt
-    AES_cfb128_encrypt
-    AES_cfb8_encrypt
-    AES_ctr128_encrypt
-    AES_decrypt
-    AES_ecb_encrypt
-    AES_encrypt
-    AES_ige_encrypt
-    AES_ofb128_encrypt
-    AES_options
-    AES_set_decrypt_key
-    AES_set_encrypt_key
-    AES_unwrap_key
-    AES_wrap_key
-    asn1_add_error
-    ASN1_add_oid_module
-    ASN1_BIT_STRING_check
-    ASN1_BIT_STRING_free
-    ASN1_BIT_STRING_get_bit
-    ASN1_BIT_STRING_name_print
-    ASN1_BIT_STRING_new
-    ASN1_BIT_STRING_num_asc
-    ASN1_BIT_STRING_set
-    ASN1_BIT_STRING_set_asc
-    ASN1_BIT_STRING_set_bit
-    ASN1_BMPSTRING_free
-    ASN1_BMPSTRING_new
-    ASN1_bn_print
-    ASN1_check_infinite_end
-    ASN1_const_check_infinite_end
-    asn1_const_Finish
-    ASN1_d2i_bio
-    ASN1_d2i_fp
-    ASN1_digest
-    asn1_do_adb
-    asn1_do_lock
-    ASN1_dup
-    asn1_enc_free
-    asn1_enc_init
-    asn1_enc_restore
-    asn1_enc_save
-    ASN1_ENUMERATED_free
-    ASN1_ENUMERATED_get
-    ASN1_ENUMERATED_new
-    ASN1_ENUMERATED_set
-    ASN1_ENUMERATED_to_BN
-    asn1_ex_c2i
-    asn1_ex_i2c
-    asn1_Finish
-    ASN1_GENERALIZEDTIME_adj
-    ASN1_GENERALIZEDTIME_check
-    ASN1_GENERALIZEDTIME_free
-    ASN1_GENERALIZEDTIME_new
-    ASN1_GENERALIZEDTIME_print
-    ASN1_GENERALIZEDTIME_set
-    ASN1_GENERALIZEDTIME_set_string
-    ASN1_GENERALSTRING_free
-    ASN1_GENERALSTRING_new
-    ASN1_generate_nconf
-    ASN1_generate_v3
-    asn1_get_choice_selector
-    asn1_get_field_ptr
-    ASN1_get_object
-    asn1_GetSequence
-    ASN1_i2d_bio
-    ASN1_i2d_fp
-    ASN1_IA5STRING_free
-    ASN1_IA5STRING_new
-    ASN1_INTEGER_cmp
-    ASN1_INTEGER_dup
-    ASN1_INTEGER_free
-    ASN1_INTEGER_get
-    ASN1_INTEGER_new
-    ASN1_INTEGER_set
-    ASN1_INTEGER_to_BN
-    ASN1_item_d2i
-    ASN1_item_d2i_bio
-    ASN1_item_d2i_fp
-    ASN1_item_digest
-    ASN1_item_dup
-    ASN1_item_ex_d2i
-    ASN1_item_ex_free
-    ASN1_item_ex_i2d
-    ASN1_item_ex_new
-    ASN1_item_free
-    ASN1_item_i2d
-    ASN1_item_i2d_bio
-    ASN1_item_i2d_fp
-    ASN1_item_ndef_i2d
-    ASN1_item_new
-    ASN1_item_pack
-    ASN1_item_print
-    ASN1_item_sign
-    ASN1_item_sign_ctx
-    ASN1_item_unpack
-    ASN1_item_verify
-    ASN1_mbstring_copy
-    ASN1_mbstring_ncopy
-    ASN1_NULL_free
-    ASN1_NULL_new
-    ASN1_OBJECT_create
-    ASN1_OBJECT_free
-    ASN1_OBJECT_new
-    ASN1_object_size
-    ASN1_OCTET_STRING_cmp
-    ASN1_OCTET_STRING_dup
-    ASN1_OCTET_STRING_free
-    ASN1_OCTET_STRING_new
-    ASN1_OCTET_STRING_set
-    ASN1_pack_string
-    ASN1_parse
-    ASN1_parse_dump
-    ASN1_PCTX_free
-    ASN1_PCTX_get_cert_flags
-    ASN1_PCTX_get_flags
-    ASN1_PCTX_get_nm_flags
-    ASN1_PCTX_get_oid_flags
-    ASN1_PCTX_get_str_flags
-    ASN1_PCTX_new
-    ASN1_PCTX_set_cert_flags
-    ASN1_PCTX_set_flags
-    ASN1_PCTX_set_nm_flags
-    ASN1_PCTX_set_oid_flags
-    ASN1_PCTX_set_str_flags
-    ASN1_primitive_free
-    ASN1_primitive_new
-    ASN1_PRINTABLE_free
-    ASN1_PRINTABLE_new
-    ASN1_PRINTABLE_type
-    ASN1_PRINTABLESTRING_free
-    ASN1_PRINTABLESTRING_new
-    ASN1_put_eoc
-    ASN1_put_object
-    ASN1_seq_pack
-    ASN1_seq_unpack
-    asn1_set_choice_selector
-    ASN1_sign
-    ASN1_STRING_cmp
-    ASN1_STRING_copy
-    ASN1_STRING_data
-    ASN1_STRING_dup
-    ASN1_STRING_free
-    ASN1_STRING_get_default_mask
-    ASN1_STRING_length
-    ASN1_STRING_length_set
-    ASN1_STRING_new
-    ASN1_STRING_print
-    ASN1_STRING_print_ex
-    ASN1_STRING_print_ex_fp
-    ASN1_STRING_set
-    ASN1_STRING_set_by_NID
-    ASN1_STRING_set_default_mask
-    ASN1_STRING_set_default_mask_asc
-    ASN1_STRING_set0
-    ASN1_STRING_TABLE_add
-    ASN1_STRING_TABLE_cleanup
-    ASN1_STRING_TABLE_get
-    ASN1_STRING_to_UTF8
-    ASN1_STRING_type
-    ASN1_STRING_type_new
-    ASN1_T61STRING_free
-    ASN1_T61STRING_new
-    ASN1_tag2bit
-    ASN1_tag2str
-    ASN1_template_d2i
-    ASN1_template_free
-    ASN1_template_i2d
-    ASN1_template_new
-    asn1_template_print_ctx
-    ASN1_TIME_adj
-    ASN1_TIME_check
-    ASN1_TIME_free
-    ASN1_TIME_new
-    ASN1_TIME_print
-    ASN1_TIME_set
-    ASN1_TIME_set_string
-    ASN1_TIME_to_generalizedtime
-    ASN1_TYPE_cmp
-    ASN1_TYPE_free
-    ASN1_TYPE_get
-    ASN1_TYPE_get_int_octetstring
-    ASN1_TYPE_get_octetstring
-    ASN1_TYPE_new
-    ASN1_TYPE_set
-    ASN1_TYPE_set_int_octetstring
-    ASN1_TYPE_set_octetstring
-    ASN1_TYPE_set1
-    ASN1_UNIVERSALSTRING_free
-    ASN1_UNIVERSALSTRING_new
-    ASN1_UNIVERSALSTRING_to_string
-    ASN1_unpack_string
-    ASN1_UTCTIME_adj
-    ASN1_UTCTIME_check
-    ASN1_UTCTIME_cmp_time_t
-    ASN1_UTCTIME_free
-    ASN1_UTCTIME_new
-    ASN1_UTCTIME_print
-    ASN1_UTCTIME_set
-    ASN1_UTCTIME_set_string
-    ASN1_UTF8STRING_free
-    ASN1_UTF8STRING_new
-    ASN1_verify
-    ASN1_VISIBLESTRING_free
-    ASN1_VISIBLESTRING_new
-    AUTHORITY_INFO_ACCESS_free
-    AUTHORITY_INFO_ACCESS_new
-    AUTHORITY_KEYID_free
-    AUTHORITY_KEYID_new
-    BASIC_CONSTRAINTS_free
-    BASIC_CONSTRAINTS_new
-    BF_cbc_encrypt
-    BF_cfb64_encrypt
-    BF_decrypt
-    BF_ecb_encrypt
-    BF_encrypt
-    BF_ofb64_encrypt
-    BF_options
-    BF_set_key
-    BIO_accept
-    BIO_asn1_get_prefix
-    BIO_asn1_get_suffix
-    BIO_asn1_set_prefix
-    BIO_asn1_set_suffix
-    BIO_callback_ctrl
-    BIO_clear_flags
-    BIO_CONNECT_free
-    BIO_CONNECT_new
-    BIO_copy_next_retry
-    BIO_ctrl
-    BIO_ctrl_get_read_request
-    BIO_ctrl_get_write_guarantee
-    BIO_ctrl_pending
-    BIO_ctrl_reset_read_request
-    BIO_ctrl_wpending
-    BIO_debug_callback
-    BIO_dgram_non_fatal_error
-    BIO_dump
-    BIO_dump_cb
-    BIO_dump_fp
-    BIO_dump_indent
-    BIO_dump_indent_cb
-    BIO_dump_indent_fp
-    BIO_dup_chain
-    BIO_f_asn1
-    BIO_f_base64
-    BIO_f_buffer
-    BIO_f_cipher
-    BIO_f_md
-    BIO_f_nbio_test
-    BIO_f_null
-    BIO_f_reliable
-    BIO_fd_non_fatal_error
-    BIO_fd_should_retry
-    BIO_find_type
-    BIO_free
-    BIO_free_all
-    BIO_get_accept_socket
-    BIO_get_callback
-    BIO_get_callback_arg
-    BIO_get_ex_data
-    BIO_get_ex_new_index
-    BIO_get_host_ip
-    BIO_get_port
-    BIO_get_retry_BIO
-    BIO_get_retry_reason
-    BIO_gethostbyname
-    BIO_gets
-    BIO_indent
-    BIO_int_ctrl
-    BIO_method_name
-    BIO_method_type
-    BIO_new
-    BIO_new_accept
-    BIO_new_bio_pair
-    BIO_new_CMS
-    BIO_new_connect
-    BIO_new_dgram
-    BIO_new_fd
-    BIO_new_file
-    BIO_new_fp
-    BIO_new_mem_buf
-    BIO_new_NDEF
-    BIO_new_PKCS7
-    BIO_new_socket
-    BIO_next
-    BIO_nread
-    BIO_nread0
-    BIO_number_read
-    BIO_number_written
-    BIO_nwrite
-    BIO_nwrite0
-    BIO_pop
-    BIO_printf
-    BIO_ptr_ctrl
-    BIO_push
-    BIO_puts
-    BIO_read
-    BIO_s_accept
-    BIO_s_bio
-    BIO_s_connect
-    BIO_s_datagram
-    BIO_s_fd
-    BIO_s_file
-    BIO_s_mem
-    BIO_s_null
-    BIO_s_socket
-    BIO_set
-    BIO_set_callback
-    BIO_set_callback_arg
-    BIO_set_cipher
-    BIO_set_ex_data
-    BIO_set_flags
-    BIO_set_tcp_ndelay
-    BIO_snprintf
-    BIO_sock_cleanup
-    BIO_sock_error
-    BIO_sock_init
-    BIO_sock_non_fatal_error
-    BIO_sock_should_retry
-    BIO_socket_ioctl
-    BIO_socket_nbio
-    BIO_test_flags
-    BIO_vfree
-    BIO_vprintf
-    BIO_vsnprintf
-    BIO_write
-    BN_add
-    bn_add_part_words
-    BN_add_word
-    bn_add_words
-    BN_asc2bn
-    BN_bin2bn
-    BN_BLINDING_convert
-    BN_BLINDING_convert_ex
-    BN_BLINDING_create_param
-    BN_BLINDING_free
-    BN_BLINDING_get_flags
-    BN_BLINDING_invert
-    BN_BLINDING_invert_ex
-    BN_BLINDING_new
-    BN_BLINDING_set_flags
-    BN_BLINDING_thread_id
-    BN_BLINDING_update
-    BN_bn2bin
-    BN_bn2dec
-    BN_bn2hex
-    BN_bn2mpi
-    BN_bntest_rand
-    BN_clear
-    BN_clear_bit
-    BN_clear_free
-    BN_cmp
-    bn_cmp_part_words
-    bn_cmp_words
-    BN_consttime_swap
-    BN_copy
-    BN_CTX_end
-    BN_CTX_free
-    BN_CTX_get
-    BN_CTX_new
-    BN_CTX_start
-    BN_dec2bn
-    BN_div
-    BN_div_recp
-    BN_div_word
-    bn_div_words
-    BN_dup
-    BN_exp
-    bn_expand2
-    BN_free
-    BN_from_montgomery
-    BN_gcd
-    BN_GENCB_call
-    BN_generate_prime_ex
-    BN_get_word
-    BN_get0_nist_prime_192
-    BN_get0_nist_prime_224
-    BN_get0_nist_prime_256
-    BN_get0_nist_prime_384
-    BN_get0_nist_prime_521
-    BN_GF2m_add
-    BN_GF2m_arr2poly
-    BN_GF2m_mod
-    BN_GF2m_mod_arr
-    BN_GF2m_mod_div
-    BN_GF2m_mod_div_arr
-    BN_GF2m_mod_exp
-    BN_GF2m_mod_exp_arr
-    BN_GF2m_mod_inv
-    BN_GF2m_mod_inv_arr
-    BN_GF2m_mod_mul
-    BN_GF2m_mod_mul_arr
-    BN_GF2m_mod_solve_quad
-    BN_GF2m_mod_solve_quad_arr
-    BN_GF2m_mod_sqr
-    BN_GF2m_mod_sqr_arr
-    BN_GF2m_mod_sqrt
-    BN_GF2m_mod_sqrt_arr
-    BN_GF2m_poly2arr
-    BN_hex2bn
-    BN_init
-    BN_is_bit_set
-    BN_is_prime_ex
-    BN_is_prime_fasttest_ex
-    BN_kronecker
-    BN_lshift
-    BN_lshift1
-    BN_mask_bits
-    BN_mod_add
-    BN_mod_add_quick
-    BN_mod_exp
-    BN_mod_exp_mont
-    BN_mod_exp_mont_consttime
-    BN_mod_exp_mont_word
-    BN_mod_exp_recp
-    BN_mod_exp_simple
-    BN_mod_exp2_mont
-    BN_mod_inverse
-    BN_mod_lshift
-    BN_mod_lshift_quick
-    BN_mod_lshift1
-    BN_mod_lshift1_quick
-    BN_mod_mul
-    BN_mod_mul_montgomery
-    BN_mod_mul_reciprocal
-    BN_mod_sqr
-    BN_mod_sqrt
-    BN_mod_sub
-    BN_mod_sub_quick
-    BN_mod_word
-    BN_MONT_CTX_copy
-    BN_MONT_CTX_free
-    BN_MONT_CTX_init
-    BN_MONT_CTX_new
-    BN_MONT_CTX_set
-    BN_MONT_CTX_set_locked
-    BN_mpi2bn
-    BN_mul
-    bn_mul_add_words
-    bn_mul_comba4
-    bn_mul_comba8
-    bn_mul_high
-    bn_mul_low_normal
-    bn_mul_low_recursive
-    bn_mul_normal
-    bn_mul_part_recursive
-    bn_mul_recursive
-    BN_mul_word
-    bn_mul_words
-    BN_new
-    BN_nist_mod_192
-    BN_nist_mod_224
-    BN_nist_mod_256
-    BN_nist_mod_384
-    BN_nist_mod_521
-    BN_nnmod
-    BN_num_bits
-    BN_num_bits_word
-    BN_options
-    BN_print
-    BN_print_fp
-    BN_pseudo_rand
-    BN_pseudo_rand_range
-    BN_rand
-    BN_rand_range
-    BN_reciprocal
-    BN_RECP_CTX_free
-    BN_RECP_CTX_init
-    BN_RECP_CTX_new
-    BN_RECP_CTX_set
-    BN_rshift
-    BN_rshift1
-    BN_set_bit
-    BN_set_negative
-    BN_set_word
-    BN_sqr
-    bn_sqr_comba4
-    bn_sqr_comba8
-    bn_sqr_normal
-    bn_sqr_recursive
-    bn_sqr_words
-    BN_sub
-    bn_sub_part_words
-    BN_sub_word
-    bn_sub_words
-    BN_swap
-    BN_to_ASN1_ENUMERATED
-    BN_to_ASN1_INTEGER
-    BN_uadd
-    BN_ucmp
-    BN_usub
-    BN_value_one
-    BN_X931_derive_prime_ex
-    BN_X931_generate_prime_ex
-    BN_X931_generate_Xpq
-    BUF_MEM_free
-    BUF_MEM_grow
-    BUF_MEM_grow_clean
-    BUF_MEM_new
-    BUF_memdup
-    BUF_reverse
-    BUF_strdup
-    BUF_strlcat
-    BUF_strlcpy
-    BUF_strndup
-    c2i_ASN1_BIT_STRING
-    c2i_ASN1_INTEGER
-    c2i_ASN1_OBJECT
-    CERTIFICATEPOLICIES_free
-    CERTIFICATEPOLICIES_new
-    check_defer
-    CMAC_CTX_cleanup
-    CMAC_CTX_copy
-    CMAC_CTX_free
-    CMAC_CTX_get0_cipher_ctx
-    CMAC_CTX_new
-    CMAC_Final
-    CMAC_Init
-    CMAC_resume
-    CMAC_Update
-    CMS_add_simple_smimecap
-    CMS_add_smimecap
-    CMS_add_standard_smimecap
-    CMS_add0_cert
-    CMS_add0_CertificateChoices
-    CMS_add0_crl
-    CMS_add0_recipient_key
-    CMS_add0_recipient_password
-    CMS_add0_RevocationInfoChoice
-    CMS_add1_cert
-    CMS_add1_crl
-    CMS_add1_ReceiptRequest
-    CMS_add1_recipient_cert
-    CMS_add1_signer
-    CMS_compress
-    cms_content_bio
-    CMS_ContentInfo_free
-    CMS_ContentInfo_new
-    CMS_ContentInfo_print_ctx
-    CMS_data
-    cms_Data_create
-    CMS_data_create
-    CMS_dataFinal
-    CMS_dataInit
-    CMS_decrypt
-    CMS_decrypt_set1_key
-    CMS_decrypt_set1_password
-    CMS_decrypt_set1_pkey
-    CMS_digest_create
-    CMS_digest_verify
-    cms_DigestAlgorithm_find_ctx
-    cms_DigestAlgorithm_init_bio
-    cms_DigestAlgorithm_set
-    cms_DigestedData_create
-    cms_DigestedData_do_final
-    cms_DigestedData_init_bio
-    cms_encode_Receipt
-    CMS_encrypt
-    cms_EncryptedContent_init
-    cms_EncryptedContent_init_bio
-    CMS_EncryptedData_decrypt
-    CMS_EncryptedData_encrypt
-    cms_EncryptedData_init_bio
-    CMS_EncryptedData_set1_key
-    CMS_EnvelopedData_create
-    cms_EnvelopedData_init_bio
-    CMS_final
-    CMS_get0_content
-    CMS_get0_eContentType
-    cms_get0_enveloped
-    CMS_get0_RecipientInfos
-    CMS_get0_SignerInfos
-    CMS_get0_signers
-    CMS_get0_type
-    CMS_get1_certs
-    CMS_get1_crls
-    CMS_get1_ReceiptRequest
-    CMS_is_detached
-    cms_msgSigDigest_add1
-    cms_Receipt_verify
-    CMS_ReceiptRequest_create0
-    CMS_ReceiptRequest_free
-    CMS_ReceiptRequest_get0_values
-    CMS_ReceiptRequest_new
-    CMS_RecipientInfo_decrypt
-    CMS_RecipientInfo_kekri_get0_id
-    CMS_RecipientInfo_kekri_id_cmp
-    CMS_RecipientInfo_ktri_cert_cmp
-    CMS_RecipientInfo_ktri_get0_algs
-    CMS_RecipientInfo_ktri_get0_signer_id
-    cms_RecipientInfo_pwri_crypt
-    CMS_RecipientInfo_set0_key
-    CMS_RecipientInfo_set0_password
-    CMS_RecipientInfo_set0_pkey
-    CMS_RecipientInfo_type
-    CMS_set_detached
-    CMS_set1_eContentType
-    cms_set1_SignerIdentifier
-    CMS_set1_signers_certs
-    CMS_sign
-    CMS_sign_receipt
-    CMS_signed_add1_attr
-    CMS_signed_add1_attr_by_NID
-    CMS_signed_add1_attr_by_OBJ
-    CMS_signed_add1_attr_by_txt
-    CMS_signed_delete_attr
-    CMS_signed_get_attr
-    CMS_signed_get_attr_by_NID
-    CMS_signed_get_attr_by_OBJ
-    CMS_signed_get_attr_count
-    CMS_signed_get0_data_by_OBJ
-    cms_SignedData_final
-    CMS_SignedData_init
-    cms_SignedData_init_bio
-    cms_SignerIdentifier_cert_cmp
-    cms_SignerIdentifier_get0_signer_id
-    CMS_SignerInfo_cert_cmp
-    CMS_SignerInfo_get0_algs
-    CMS_SignerInfo_get0_signer_id
-    CMS_SignerInfo_set1_signer_cert
-    CMS_SignerInfo_sign
-    CMS_SignerInfo_verify
-    CMS_SignerInfo_verify_content
-    CMS_stream
-    CMS_uncompress
-    CMS_unsigned_add1_attr
-    CMS_unsigned_add1_attr_by_NID
-    CMS_unsigned_add1_attr_by_OBJ
-    CMS_unsigned_add1_attr_by_txt
-    CMS_unsigned_delete_attr
-    CMS_unsigned_get_attr
-    CMS_unsigned_get_attr_by_NID
-    CMS_unsigned_get_attr_by_OBJ
-    CMS_unsigned_get_attr_count
-    CMS_unsigned_get0_data_by_OBJ
-    CMS_verify
-    CMS_verify_receipt
-    CONF_dump_bio
-    CONF_dump_fp
-    CONF_free
-    CONF_get_number
-    CONF_get_section
-    CONF_get_string
-    CONF_get1_default_config_file
-    CONF_imodule_get_flags
-    CONF_imodule_get_module
-    CONF_imodule_get_name
-    CONF_imodule_get_usr_data
-    CONF_imodule_get_value
-    CONF_imodule_set_flags
-    CONF_imodule_set_usr_data
-    CONF_load
-    CONF_load_bio
-    CONF_load_fp
-    CONF_module_add
-    CONF_module_get_usr_data
-    CONF_module_set_usr_data
-    CONF_modules_finish
-    CONF_modules_free
-    CONF_modules_load
-    CONF_modules_load_file
-    CONF_modules_unload
-    CONF_parse_list
-    CONF_set_default_method
-    CONF_set_nconf
-    CRL_DIST_POINTS_free
-    CRL_DIST_POINTS_new
-    CRYPTO_add_lock
-    CRYPTO_cbc128_decrypt
-    CRYPTO_cbc128_encrypt
-    CRYPTO_ccm128_aad
-    CRYPTO_ccm128_decrypt
-    CRYPTO_ccm128_decrypt_ccm64
-    CRYPTO_ccm128_encrypt
-    CRYPTO_ccm128_encrypt_ccm64
-    CRYPTO_ccm128_init
-    CRYPTO_ccm128_setiv
-    CRYPTO_ccm128_tag
-    CRYPTO_cfb128_1_encrypt
-    CRYPTO_cfb128_8_encrypt
-    CRYPTO_cfb128_encrypt
-    CRYPTO_cleanup_all_ex_data
-    CRYPTO_ctr128_encrypt
-    CRYPTO_ctr128_encrypt_ctr32
-    CRYPTO_cts128_decrypt
-    CRYPTO_cts128_decrypt_block
-    CRYPTO_cts128_encrypt
-    CRYPTO_cts128_encrypt_block
-    CRYPTO_dbg_free
-    CRYPTO_dbg_get_options
-    CRYPTO_dbg_malloc
-    CRYPTO_dbg_realloc
-    CRYPTO_dbg_set_options
-    CRYPTO_destroy_dynlockid
-    CRYPTO_dup_ex_data
-    CRYPTO_ex_data_new_class
-    CRYPTO_free
-    CRYPTO_free_ex_data
-    CRYPTO_free_locked
-    CRYPTO_gcm128_aad
-    CRYPTO_gcm128_decrypt
-    CRYPTO_gcm128_decrypt_ctr32
-    CRYPTO_gcm128_encrypt
-    CRYPTO_gcm128_encrypt_ctr32
-    CRYPTO_gcm128_finish
-    CRYPTO_gcm128_init
-    CRYPTO_gcm128_new
-    CRYPTO_gcm128_release
-    CRYPTO_gcm128_setiv
-    CRYPTO_gcm128_tag
-    CRYPTO_get_add_lock_callback
-    CRYPTO_get_dynlock_create_callback
-    CRYPTO_get_dynlock_destroy_callback
-    CRYPTO_get_dynlock_lock_callback
-    CRYPTO_get_dynlock_value
-    CRYPTO_get_ex_data
-    CRYPTO_get_ex_data_implementation
-    CRYPTO_get_ex_new_index
-    CRYPTO_get_id_callback
-    CRYPTO_get_lock_name
-    CRYPTO_get_locked_mem_ex_functions
-    CRYPTO_get_locked_mem_functions
-    CRYPTO_get_locking_callback
-    CRYPTO_get_mem_debug_functions
-    CRYPTO_get_mem_debug_options
-    CRYPTO_get_mem_ex_functions
-    CRYPTO_get_mem_functions
-    CRYPTO_get_new_dynlockid
-    CRYPTO_get_new_lockid
-    CRYPTO_is_mem_check_on
-    CRYPTO_lock
-    CRYPTO_malloc
-    CRYPTO_malloc_locked
-    CRYPTO_mem_ctrl
-    CRYPTO_mem_leaks
-    CRYPTO_mem_leaks_cb
-    CRYPTO_mem_leaks_fp
-    CRYPTO_memcmp
-    CRYPTO_new_ex_data
-    CRYPTO_nistcts128_decrypt
-    CRYPTO_nistcts128_decrypt_block
-    CRYPTO_nistcts128_encrypt
-    CRYPTO_nistcts128_encrypt_block
-    CRYPTO_num_locks
-    CRYPTO_ofb128_encrypt
-    CRYPTO_pop_info
-    CRYPTO_push_info_
-    CRYPTO_realloc
-    CRYPTO_realloc_clean
-    CRYPTO_remalloc
-    CRYPTO_remove_all_info
-    CRYPTO_set_add_lock_callback
-    CRYPTO_set_dynlock_create_callback
-    CRYPTO_set_dynlock_destroy_callback
-    CRYPTO_set_dynlock_lock_callback
-    CRYPTO_set_ex_data
-    CRYPTO_set_ex_data_implementation
-    CRYPTO_set_id_callback
-    CRYPTO_set_locked_mem_ex_functions
-    CRYPTO_set_locked_mem_functions
-    CRYPTO_set_locking_callback
-    CRYPTO_set_mem_debug_functions
-    CRYPTO_set_mem_debug_options
-    CRYPTO_set_mem_ex_functions
-    CRYPTO_set_mem_functions
-    CRYPTO_strdup
-    CRYPTO_thread_id
-    CRYPTO_THREADID_cmp
-    CRYPTO_THREADID_cpy
-    CRYPTO_THREADID_current
-    CRYPTO_THREADID_get_callback
-    CRYPTO_THREADID_hash
-    CRYPTO_THREADID_set_callback
-    CRYPTO_THREADID_set_numeric
-    CRYPTO_THREADID_set_pointer
-    CRYPTO_xts128_encrypt
-    d2i_ACCESS_DESCRIPTION
-    d2i_ASN1_BIT_STRING
-    d2i_ASN1_BMPSTRING
-    d2i_ASN1_BOOLEAN
-    d2i_ASN1_bytes
-    d2i_ASN1_ENUMERATED
-    d2i_ASN1_GENERALIZEDTIME
-    d2i_ASN1_GENERALSTRING
-    d2i_ASN1_IA5STRING
-    d2i_ASN1_INTEGER
-    d2i_ASN1_NULL
-    d2i_ASN1_OBJECT
-    d2i_ASN1_OCTET_STRING
-    d2i_ASN1_PRINTABLE
-    d2i_ASN1_PRINTABLESTRING
-    d2i_ASN1_SEQUENCE_ANY
-    d2i_ASN1_SET
-    d2i_ASN1_SET_ANY
-    d2i_ASN1_T61STRING
-    d2i_ASN1_TIME
-    d2i_ASN1_TYPE
-    d2i_ASN1_type_bytes
-    d2i_ASN1_UINTEGER
-    d2i_ASN1_UNIVERSALSTRING
-    d2i_ASN1_UTCTIME
-    d2i_ASN1_UTF8STRING
-    d2i_ASN1_VISIBLESTRING
-    d2i_AUTHORITY_INFO_ACCESS
-    d2i_AUTHORITY_KEYID
-    d2i_AutoPrivateKey
-    d2i_BASIC_CONSTRAINTS
-    d2i_CERTIFICATEPOLICIES
-    d2i_CMS_bio
-    d2i_CMS_ContentInfo
-    d2i_CMS_ReceiptRequest
-    d2i_CRL_DIST_POINTS
-    d2i_DHparams
-    d2i_DIRECTORYSTRING
-    d2i_DISPLAYTEXT
-    d2i_DIST_POINT
-    d2i_DIST_POINT_NAME
-    d2i_EDIPARTYNAME
-    d2i_EXTENDED_KEY_USAGE
-    d2i_GENERAL_NAME
-    d2i_GENERAL_NAMES
-    d2i_ISSUING_DIST_POINT
-    d2i_NETSCAPE_CERT_SEQUENCE
-    d2i_NETSCAPE_ENCRYPTED_PKEY
-    d2i_NETSCAPE_PKEY
-    d2i_Netscape_RSA
-    d2i_NETSCAPE_SPKAC
-    d2i_NETSCAPE_SPKI
-    d2i_NETSCAPE_X509
-    d2i_NOTICEREF
-    d2i_OCSP_BASICRESP
-    d2i_OCSP_CERTID
-    d2i_OCSP_CERTSTATUS
-    d2i_OCSP_CRLID
-    d2i_OCSP_ONEREQ
-    d2i_OCSP_REQINFO
-    d2i_OCSP_REQUEST
-    d2i_OCSP_RESPBYTES
-    d2i_OCSP_RESPDATA
-    d2i_OCSP_RESPID
-    d2i_OCSP_RESPONSE
-    d2i_OCSP_REVOKEDINFO
-    d2i_OCSP_SERVICELOC
-    d2i_OCSP_SIGNATURE
-    d2i_OCSP_SINGLERESP
-    d2i_OTHERNAME
-    d2i_PBE2PARAM
-    d2i_PBEPARAM
-    d2i_PBKDF2PARAM
-    d2i_PKCS12
-    d2i_PKCS12_BAGS
-    d2i_PKCS12_bio
-    d2i_PKCS12_fp
-    d2i_PKCS12_MAC_DATA
-    d2i_PKCS12_SAFEBAG
-    d2i_PKCS7
-    d2i_PKCS7_bio
-    d2i_PKCS7_DIGEST
-    d2i_PKCS7_ENC_CONTENT
-    d2i_PKCS7_ENCRYPT
-    d2i_PKCS7_ENVELOPE
-    d2i_PKCS7_fp
-    d2i_PKCS7_ISSUER_AND_SERIAL
-    d2i_PKCS7_RECIP_INFO
-    d2i_PKCS7_SIGN_ENVELOPE
-    d2i_PKCS7_SIGNED
-    d2i_PKCS7_SIGNER_INFO
-    d2i_PKCS8_bio
-    d2i_PKCS8_fp
-    d2i_PKCS8_PRIV_KEY_INFO
-    d2i_PKCS8_PRIV_KEY_INFO_bio
-    d2i_PKCS8_PRIV_KEY_INFO_fp
-    d2i_PKCS8PrivateKey_bio
-    d2i_PKCS8PrivateKey_fp
-    d2i_PKEY_USAGE_PERIOD
-    d2i_POLICYINFO
-    d2i_POLICYQUALINFO
-    d2i_PrivateKey
-    d2i_PrivateKey_bio
-    d2i_PrivateKey_fp
-    d2i_PROXY_CERT_INFO_EXTENSION
-    d2i_PROXY_POLICY
-    d2i_PUBKEY
-    d2i_PUBKEY_bio
-    d2i_PUBKEY_fp
-    d2i_PublicKey
-    d2i_RSA_NET
-    d2i_RSA_PSS_PARAMS
-    d2i_RSA_PUBKEY
-    d2i_RSA_PUBKEY_bio
-    d2i_RSA_PUBKEY_fp
-    d2i_RSAPrivateKey
-    d2i_RSAPrivateKey_bio
-    d2i_RSAPrivateKey_fp
-    d2i_RSAPublicKey
-    d2i_RSAPublicKey_bio
-    d2i_RSAPublicKey_fp
-    d2i_SXNET
-    d2i_SXNETID
-    d2i_USERNOTICE
-    d2i_X509
-    d2i_X509_ALGOR
-    d2i_X509_ALGORS
-    d2i_X509_ATTRIBUTE
-    d2i_X509_AUX
-    d2i_X509_bio
-    d2i_X509_CERT_AUX
-    d2i_X509_CERT_PAIR
-    d2i_X509_CINF
-    d2i_X509_CRL
-    d2i_X509_CRL_bio
-    d2i_X509_CRL_fp
-    d2i_X509_CRL_INFO
-    d2i_X509_EXTENSION
-    d2i_X509_EXTENSIONS
-    d2i_X509_fp
-    d2i_X509_NAME
-    d2i_X509_NAME_ENTRY
-    d2i_X509_PKEY
-    d2i_X509_PUBKEY
-    d2i_X509_REQ
-    d2i_X509_REQ_bio
-    d2i_X509_REQ_fp
-    d2i_X509_REQ_INFO
-    d2i_X509_REVOKED
-    d2i_X509_SIG
-    d2i_X509_VAL
-    DH_check
-    DH_check_pub_key
-    DH_compute_key
-    DH_free
-    DH_generate_key
-    DH_generate_parameters
-    DH_generate_parameters_ex
-    DH_get_default_method
-    DH_get_ex_data
-    DH_get_ex_new_index
-    DH_new
-    DH_new_method
-    DH_OpenSSL
-    DH_set_default_method
-    DH_set_ex_data
-    DH_set_method
-    DH_size
-    DH_up_ref
-    DHparams_dup
-    DHparams_print
-    DHparams_print_fp
-    DIRECTORYSTRING_free
-    DIRECTORYSTRING_new
-    DISPLAYTEXT_free
-    DISPLAYTEXT_new
-    DIST_POINT_free
-    DIST_POINT_NAME_free
-    DIST_POINT_NAME_new
-    DIST_POINT_new
-    DIST_POINT_set_dpname
-    DSO_bind_func
-    DSO_bind_var
-    DSO_convert_filename
-    DSO_ctrl
-    DSO_flags
-    DSO_free
-    DSO_get_default_method
-    DSO_get_filename
-    DSO_get_loaded_filename
-    DSO_get_method
-    DSO_global_lookup
-    DSO_load
-    DSO_merge
-    DSO_METHOD_null
-    DSO_METHOD_openssl
-    DSO_new
-    DSO_new_method
-    DSO_pathbyaddr
-    DSO_set_default_method
-    DSO_set_filename
-    DSO_set_method
-    DSO_set_name_converter
-    DSO_up_ref
-    EDIPARTYNAME_free
-    EDIPARTYNAME_new
-    ERR_add_error_data
-    ERR_add_error_vdata
-    ERR_clear_error
-    ERR_error_string
-    ERR_error_string_n
-    ERR_free_strings
-    ERR_func_error_string
-    ERR_get_err_state_table
-    ERR_get_error
-    ERR_get_error_line
-    ERR_get_error_line_data
-    ERR_get_implementation
-    ERR_get_next_error_library
-    ERR_get_state
-    ERR_get_string_table
-    ERR_lib_error_string
-    ERR_load_ASN1_strings
-    ERR_load_BIO_strings
-    ERR_load_BN_strings
-    ERR_load_BUF_strings
-    ERR_load_CMS_strings
-    ERR_load_CONF_strings
-    ERR_load_CRYPTO_strings
-    ERR_load_crypto_strings
-    ERR_load_DH_strings
-    ERR_load_DSO_strings
-    ERR_load_ERR_strings
-    ERR_load_EVP_strings
-    ERR_load_OBJ_strings
-    ERR_load_OCSP_strings
-    ERR_load_PEM_strings
-    ERR_load_PKCS12_strings
-    ERR_load_PKCS7_strings
-    ERR_load_RAND_strings
-    ERR_load_RSA_strings
-    ERR_load_strings
-    ERR_load_UI_strings
-    ERR_load_X509_strings
-    ERR_load_X509V3_strings
-    ERR_peek_error
-    ERR_peek_error_line
-    ERR_peek_error_line_data
-    ERR_peek_last_error
-    ERR_peek_last_error_line
-    ERR_peek_last_error_line_data
-    ERR_pop_to_mark
-    ERR_print_errors
-    ERR_print_errors_cb
-    ERR_print_errors_fp
-    ERR_put_error
-    ERR_reason_error_string
-    ERR_release_err_state_table
-    ERR_remove_state
-    ERR_remove_thread_state
-    ERR_set_error_data
-    ERR_set_implementation
-    ERR_set_mark
-    ERR_unload_strings
-    EVP_add_alg_module
-    EVP_add_cipher
-    EVP_add_digest
-    EVP_aes_128_cbc
-    EVP_aes_128_cbc_hmac_sha1
-    EVP_aes_128_ccm
-    EVP_aes_128_cfb1
-    EVP_aes_128_cfb128
-    EVP_aes_128_cfb8
-    EVP_aes_128_ctr
-    EVP_aes_128_ecb
-    EVP_aes_128_gcm
-    EVP_aes_128_ofb
-    EVP_aes_128_xts
-    EVP_aes_192_cbc
-    EVP_aes_192_ccm
-    EVP_aes_192_cfb1
-    EVP_aes_192_cfb128
-    EVP_aes_192_cfb8
-    EVP_aes_192_ctr
-    EVP_aes_192_ecb
-    EVP_aes_192_gcm
-    EVP_aes_192_ofb
-    EVP_aes_256_cbc
-    EVP_aes_256_cbc_hmac_sha1
-    EVP_aes_256_ccm
-    EVP_aes_256_cfb1
-    EVP_aes_256_cfb128
-    EVP_aes_256_cfb8
-    EVP_aes_256_ctr
-    EVP_aes_256_ecb
-    EVP_aes_256_gcm
-    EVP_aes_256_ofb
-    EVP_aes_256_xts
-    EVP_bf_cbc
-    EVP_bf_cfb64
-    EVP_bf_ecb
-    EVP_bf_ofb
-    EVP_BytesToKey
-    EVP_Cipher
-    EVP_CIPHER_asn1_to_param
-    EVP_CIPHER_block_size
-    EVP_CIPHER_CTX_block_size
-    EVP_CIPHER_CTX_cipher
-    EVP_CIPHER_CTX_cleanup
-    EVP_CIPHER_CTX_clear_flags
-    EVP_CIPHER_CTX_copy
-    EVP_CIPHER_CTX_ctrl
-    EVP_CIPHER_CTX_flags
-    EVP_CIPHER_CTX_free
-    EVP_CIPHER_CTX_get_app_data
-    EVP_CIPHER_CTX_init
-    EVP_CIPHER_CTX_iv_length
-    EVP_CIPHER_CTX_key_length
-    EVP_CIPHER_CTX_new
-    EVP_CIPHER_CTX_nid
-    EVP_CIPHER_CTX_rand_key
-    EVP_CIPHER_CTX_set_app_data
-    EVP_CIPHER_CTX_set_flags
-    EVP_CIPHER_CTX_set_key_length
-    EVP_CIPHER_CTX_set_padding
-    EVP_CIPHER_CTX_test_flags
-    EVP_CIPHER_do_all
-    EVP_CIPHER_do_all_sorted
-    EVP_CIPHER_flags
-    EVP_CIPHER_get_asn1_iv
-    EVP_CIPHER_iv_length
-    EVP_CIPHER_key_length
-    EVP_CIPHER_nid
-    EVP_CIPHER_param_to_asn1
-    EVP_CIPHER_set_asn1_iv
-    EVP_CIPHER_type
-    EVP_CipherFinal
-    EVP_CipherFinal_ex
-    EVP_CipherInit
-    EVP_CipherInit_ex
-    EVP_CipherUpdate
-    EVP_cleanup
-    EVP_DecodeBlock
-    EVP_DecodeFinal
-    EVP_DecodeInit
-    EVP_DecodeUpdate
-    EVP_DecryptFinal
-    EVP_DecryptFinal_ex
-    EVP_DecryptInit
-    EVP_DecryptInit_ex
-    EVP_DecryptUpdate
-    EVP_Digest
-    EVP_DigestFinal
-    EVP_DigestFinal_ex
-    EVP_DigestInit
-    EVP_DigestInit_ex
-    EVP_DigestSignFinal
-    EVP_DigestSignInit
-    EVP_DigestUpdate
-    EVP_DigestVerifyFinal
-    EVP_DigestVerifyInit
-    EVP_dss
-    EVP_dss1
-    EVP_ecdsa
-    EVP_enc_null
-    EVP_EncodeBlock
-    EVP_EncodeFinal
-    EVP_EncodeInit
-    EVP_EncodeUpdate
-    EVP_EncryptFinal
-    EVP_EncryptFinal_ex
-    EVP_EncryptInit
-    EVP_EncryptInit_ex
-    EVP_EncryptUpdate
-    EVP_get_cipherbyname
-    EVP_get_digestbyname
-    EVP_get_pw_prompt
-    EVP_MD_block_size
-    EVP_MD_CTX_cleanup
-    EVP_MD_CTX_clear_flags
-    EVP_MD_CTX_copy
-    EVP_MD_CTX_copy_ex
-    EVP_MD_CTX_create
-    EVP_MD_CTX_destroy
-    EVP_MD_CTX_init
-    EVP_MD_CTX_md
-    EVP_MD_CTX_set_flags
-    EVP_MD_CTX_test_flags
-    EVP_MD_do_all
-    EVP_MD_do_all_sorted
-    EVP_MD_flags
-    EVP_md_null
-    EVP_MD_pkey_type
-    EVP_MD_size
-    EVP_MD_type
-    EVP_md5
-    EVP_OpenFinal
-    EVP_OpenInit
-    EVP_PBE_alg_add
-    EVP_PBE_alg_add_type
-    EVP_PBE_CipherInit
-    EVP_PBE_cleanup
-    EVP_PBE_find
-    EVP_PKCS82PKEY
-    EVP_PKEY_add1_attr
-    EVP_PKEY_add1_attr_by_NID
-    EVP_PKEY_add1_attr_by_OBJ
-    EVP_PKEY_add1_attr_by_txt
-    EVP_PKEY_asn1_add_alias
-    EVP_PKEY_asn1_add0
-    EVP_PKEY_asn1_copy
-    EVP_PKEY_asn1_find
-    EVP_PKEY_asn1_find_str
-    EVP_PKEY_asn1_free
-    EVP_PKEY_asn1_get_count
-    EVP_PKEY_asn1_get0
-    EVP_PKEY_asn1_get0_info
-    EVP_PKEY_asn1_new
-    EVP_PKEY_asn1_set_ctrl
-    EVP_PKEY_asn1_set_free
-    EVP_PKEY_asn1_set_param
-    EVP_PKEY_asn1_set_private
-    EVP_PKEY_asn1_set_public
-    EVP_PKEY_assign
-    EVP_PKEY_base_id
-    EVP_PKEY_bits
-    EVP_PKEY_cmp
-    EVP_PKEY_cmp_parameters
-    EVP_PKEY_copy_parameters
-    EVP_PKEY_CTX_ctrl
-    EVP_PKEY_CTX_ctrl_str
-    EVP_PKEY_CTX_dup
-    EVP_PKEY_CTX_free
-    EVP_PKEY_CTX_get_app_data
-    EVP_PKEY_CTX_get_cb
-    EVP_PKEY_CTX_get_data
-    EVP_PKEY_CTX_get_keygen_info
-    EVP_PKEY_CTX_get_operation
-    EVP_PKEY_CTX_get0_peerkey
-    EVP_PKEY_CTX_get0_pkey
-    EVP_PKEY_CTX_new
-    EVP_PKEY_CTX_new_id
-    EVP_PKEY_CTX_set_app_data
-    EVP_PKEY_CTX_set_cb
-    EVP_PKEY_CTX_set_data
-    EVP_PKEY_CTX_set0_keygen_info
-    EVP_PKEY_decrypt
-    EVP_PKEY_decrypt_init
-    EVP_PKEY_decrypt_old
-    EVP_PKEY_delete_attr
-    EVP_PKEY_derive
-    EVP_PKEY_derive_init
-    EVP_PKEY_derive_set_peer
-    EVP_PKEY_encrypt
-    EVP_PKEY_encrypt_init
-    EVP_PKEY_encrypt_old
-    EVP_PKEY_free
-    EVP_PKEY_get_attr
-    EVP_PKEY_get_attr_by_NID
-    EVP_PKEY_get_attr_by_OBJ
-    EVP_PKEY_get_attr_count
-    EVP_PKEY_get_default_digest_nid
-    EVP_PKEY_get0
-    EVP_PKEY_get0_asn1
-    EVP_PKEY_get1_DH
-    EVP_PKEY_get1_RSA
-    EVP_PKEY_id
-    EVP_PKEY_keygen
-    EVP_PKEY_keygen_init
-    EVP_PKEY_meth_add0
-    EVP_PKEY_meth_copy
-    EVP_PKEY_meth_find
-    EVP_PKEY_meth_free
-    EVP_PKEY_meth_get0_info
-    EVP_PKEY_meth_new
-    EVP_PKEY_meth_set_cleanup
-    EVP_PKEY_meth_set_copy
-    EVP_PKEY_meth_set_ctrl
-    EVP_PKEY_meth_set_decrypt
-    EVP_PKEY_meth_set_derive
-    EVP_PKEY_meth_set_encrypt
-    EVP_PKEY_meth_set_init
-    EVP_PKEY_meth_set_keygen
-    EVP_PKEY_meth_set_paramgen
-    EVP_PKEY_meth_set_sign
-    EVP_PKEY_meth_set_signctx
-    EVP_PKEY_meth_set_verify
-    EVP_PKEY_meth_set_verify_recover
-    EVP_PKEY_meth_set_verifyctx
-    EVP_PKEY_missing_parameters
-    EVP_PKEY_new
-    EVP_PKEY_new_mac_key
-    EVP_PKEY_paramgen
-    EVP_PKEY_paramgen_init
-    EVP_PKEY_print_params
-    EVP_PKEY_print_private
-    EVP_PKEY_print_public
-    EVP_PKEY_save_parameters
-    evp_pkey_set_cb_translate
-    EVP_PKEY_set_type
-    EVP_PKEY_set_type_str
-    EVP_PKEY_set1_DH
-    EVP_PKEY_set1_RSA
-    EVP_PKEY_sign
-    EVP_PKEY_sign_init
-    EVP_PKEY_size
-    EVP_PKEY_type
-    EVP_PKEY_verify
-    EVP_PKEY_verify_init
-    EVP_PKEY_verify_recover
-    EVP_PKEY_verify_recover_init
-    EVP_PKEY2PKCS8
-    EVP_PKEY2PKCS8_broken
-    EVP_rc4
-    EVP_rc4_40
-    EVP_rc4_hmac_md5
-    EVP_read_pw_string
-    EVP_read_pw_string_min
-    EVP_SealFinal
-    EVP_SealInit
-    EVP_seed_cbc
-    EVP_seed_cfb128
-    EVP_seed_ecb
-    EVP_seed_ofb
-    EVP_set_pw_prompt
-    EVP_sha1
-    EVP_sha224
-    EVP_sha256
-    EVP_sha384
-    EVP_sha512
-    EVP_SignFinal
-    EVP_VerifyFinal
-    EXTENDED_KEY_USAGE_free
-    EXTENDED_KEY_USAGE_new
-    GENERAL_NAME_cmp
-    GENERAL_NAME_dup
-    GENERAL_NAME_free
-    GENERAL_NAME_get0_otherName
-    GENERAL_NAME_get0_value
-    GENERAL_NAME_new
-    GENERAL_NAME_print
-    GENERAL_NAME_set0_othername
-    GENERAL_NAME_set0_value
-    GENERAL_NAMES_free
-    GENERAL_NAMES_new
-    GENERAL_SUBTREE_free
-    GENERAL_SUBTREE_new
-    get_rfc2409_prime_1024
-    get_rfc2409_prime_768
-    get_rfc3526_prime_1536
-    get_rfc3526_prime_2048
-    get_rfc3526_prime_3072
-    get_rfc3526_prime_4096
-    get_rfc3526_prime_6144
-    get_rfc3526_prime_8192
-    hex_to_string
-    HMAC
-    HMAC_CTX_cleanup
-    HMAC_CTX_copy
-    HMAC_CTX_init
-    HMAC_CTX_set_flags
-    HMAC_Final
-    HMAC_Init
-    HMAC_Init_ex
-    HMAC_Update
-    i2a_ACCESS_DESCRIPTION
-    i2a_ASN1_ENUMERATED
-    i2a_ASN1_INTEGER
-    i2a_ASN1_OBJECT
-    i2a_ASN1_STRING
-    i2c_ASN1_BIT_STRING
-    i2c_ASN1_INTEGER
-    i2d_ACCESS_DESCRIPTION
-    i2d_ASN1_bio_stream
-    i2d_ASN1_BIT_STRING
-    i2d_ASN1_BMPSTRING
-    i2d_ASN1_BOOLEAN
-    i2d_ASN1_bytes
-    i2d_ASN1_ENUMERATED
-    i2d_ASN1_GENERALIZEDTIME
-    i2d_ASN1_GENERALSTRING
-    i2d_ASN1_IA5STRING
-    i2d_ASN1_INTEGER
-    i2d_ASN1_NULL
-    i2d_ASN1_OBJECT
-    i2d_ASN1_OCTET_STRING
-    i2d_ASN1_PRINTABLE
-    i2d_ASN1_PRINTABLESTRING
-    i2d_ASN1_SEQUENCE_ANY
-    i2d_ASN1_SET
-    i2d_ASN1_SET_ANY
-    i2d_ASN1_T61STRING
-    i2d_ASN1_TIME
-    i2d_ASN1_TYPE
-    i2d_ASN1_UNIVERSALSTRING
-    i2d_ASN1_UTCTIME
-    i2d_ASN1_UTF8STRING
-    i2d_ASN1_VISIBLESTRING
-    i2d_AUTHORITY_INFO_ACCESS
-    i2d_AUTHORITY_KEYID
-    i2d_BASIC_CONSTRAINTS
-    i2d_CERTIFICATEPOLICIES
-    i2d_CMS_bio
-    i2d_CMS_bio_stream
-    i2d_CMS_ContentInfo
-    i2d_CMS_ReceiptRequest
-    i2d_CRL_DIST_POINTS
-    i2d_DHparams
-    i2d_DIRECTORYSTRING
-    i2d_DISPLAYTEXT
-    i2d_DIST_POINT
-    i2d_DIST_POINT_NAME
-    i2d_EDIPARTYNAME
-    i2d_EXTENDED_KEY_USAGE
-    i2d_GENERAL_NAME
-    i2d_GENERAL_NAMES
-    i2d_ISSUING_DIST_POINT
-    i2d_NETSCAPE_CERT_SEQUENCE
-    i2d_NETSCAPE_ENCRYPTED_PKEY
-    i2d_NETSCAPE_PKEY
-    i2d_Netscape_RSA
-    i2d_NETSCAPE_SPKAC
-    i2d_NETSCAPE_SPKI
-    i2d_NETSCAPE_X509
-    i2d_NOTICEREF
-    i2d_OCSP_BASICRESP
-    i2d_OCSP_CERTID
-    i2d_OCSP_CERTSTATUS
-    i2d_OCSP_CRLID
-    i2d_OCSP_ONEREQ
-    i2d_OCSP_REQINFO
-    i2d_OCSP_REQUEST
-    i2d_OCSP_RESPBYTES
-    i2d_OCSP_RESPDATA
-    i2d_OCSP_RESPID
-    i2d_OCSP_RESPONSE
-    i2d_OCSP_REVOKEDINFO
-    i2d_OCSP_SERVICELOC
-    i2d_OCSP_SIGNATURE
-    i2d_OCSP_SINGLERESP
-    i2d_OTHERNAME
-    i2d_PBE2PARAM
-    i2d_PBEPARAM
-    i2d_PBKDF2PARAM
-    i2d_PKCS12
-    i2d_PKCS12_BAGS
-    i2d_PKCS12_bio
-    i2d_PKCS12_fp
-    i2d_PKCS12_MAC_DATA
-    i2d_PKCS12_SAFEBAG
-    i2d_PKCS7
-    i2d_PKCS7_bio
-    i2d_PKCS7_bio_stream
-    i2d_PKCS7_DIGEST
-    i2d_PKCS7_ENC_CONTENT
-    i2d_PKCS7_ENCRYPT
-    i2d_PKCS7_ENVELOPE
-    i2d_PKCS7_fp
-    i2d_PKCS7_ISSUER_AND_SERIAL
-    i2d_PKCS7_NDEF
-    i2d_PKCS7_RECIP_INFO
-    i2d_PKCS7_SIGN_ENVELOPE
-    i2d_PKCS7_SIGNED
-    i2d_PKCS7_SIGNER_INFO
-    i2d_PKCS8_bio
-    i2d_PKCS8_fp
-    i2d_PKCS8_PRIV_KEY_INFO
-    i2d_PKCS8_PRIV_KEY_INFO_bio
-    i2d_PKCS8_PRIV_KEY_INFO_fp
-    i2d_PKCS8PrivateKey_bio
-    i2d_PKCS8PrivateKey_fp
-    i2d_PKCS8PrivateKey_nid_bio
-    i2d_PKCS8PrivateKey_nid_fp
-    i2d_PKCS8PrivateKeyInfo_bio
-    i2d_PKCS8PrivateKeyInfo_fp
-    i2d_PKEY_USAGE_PERIOD
-    i2d_POLICYINFO
-    i2d_POLICYQUALINFO
-    i2d_PrivateKey
-    i2d_PrivateKey_bio
-    i2d_PrivateKey_fp
-    i2d_PROXY_CERT_INFO_EXTENSION
-    i2d_PROXY_POLICY
-    i2d_PUBKEY
-    i2d_PUBKEY_bio
-    i2d_PUBKEY_fp
-    i2d_PublicKey
-    i2d_RSA_NET
-    i2d_RSA_PSS_PARAMS
-    i2d_RSA_PUBKEY
-    i2d_RSA_PUBKEY_bio
-    i2d_RSA_PUBKEY_fp
-    i2d_RSAPrivateKey
-    i2d_RSAPrivateKey_bio
-    i2d_RSAPrivateKey_fp
-    i2d_RSAPublicKey
-    i2d_RSAPublicKey_bio
-    i2d_RSAPublicKey_fp
-    i2d_SXNET
-    i2d_SXNETID
-    i2d_USERNOTICE
-    i2d_X509
-    i2d_X509_ALGOR
-    i2d_X509_ALGORS
-    i2d_X509_ATTRIBUTE
-    i2d_X509_AUX
-    i2d_X509_bio
-    i2d_X509_CERT_AUX
-    i2d_X509_CERT_PAIR
-    i2d_X509_CINF
-    i2d_X509_CRL
-    i2d_X509_CRL_bio
-    i2d_X509_CRL_fp
-    i2d_X509_CRL_INFO
-    i2d_X509_EXTENSION
-    i2d_X509_EXTENSIONS
-    i2d_X509_fp
-    i2d_X509_NAME
-    i2d_X509_NAME_ENTRY
-    i2d_X509_PKEY
-    i2d_X509_PUBKEY
-    i2d_X509_REQ
-    i2d_X509_REQ_bio
-    i2d_X509_REQ_fp
-    i2d_X509_REQ_INFO
-    i2d_X509_REVOKED
-    i2d_X509_SIG
-    i2d_X509_VAL
-    i2s_ASN1_ENUMERATED
-    i2s_ASN1_ENUMERATED_TABLE
-    i2s_ASN1_INTEGER
-    i2s_ASN1_OCTET_STRING
-    i2t_ASN1_OBJECT
-    i2v_ASN1_BIT_STRING
-    i2v_GENERAL_NAME
-    i2v_GENERAL_NAMES
-    int_rsa_verify
-    ISSUING_DIST_POINT_free
-    ISSUING_DIST_POINT_new
-    level_add_node
-    level_find_node
-    lh_delete
-    lh_doall
-    lh_doall_arg
-    lh_free
-    lh_insert
-    lh_new
-    lh_node_stats
-    lh_node_stats_bio
-    lh_node_usage_stats
-    lh_node_usage_stats_bio
-    lh_num_items
-    lh_retrieve
-    lh_stats
-    lh_stats_bio
-    lh_strhash
-    MD5
-    md5_block_data_order
-    MD5_Final
-    MD5_Init
-    MD5_Transform
-    MD5_Update
-    name_cmp
-    NAME_CONSTRAINTS_check
-    NAME_CONSTRAINTS_free
-    NAME_CONSTRAINTS_new
-    NCONF_default
-    NCONF_dump_bio
-    NCONF_dump_fp
-    NCONF_free
-    NCONF_free_data
-    NCONF_get_number_e
-    NCONF_get_section
-    NCONF_get_string
-    NCONF_load
-    NCONF_load_bio
-    NCONF_load_fp
-    NCONF_new
-    NCONF_WIN32
-    NETSCAPE_CERT_SEQUENCE_free
-    NETSCAPE_CERT_SEQUENCE_new
-    NETSCAPE_ENCRYPTED_PKEY_free
-    NETSCAPE_ENCRYPTED_PKEY_new
-    NETSCAPE_PKEY_free
-    NETSCAPE_PKEY_new
-    NETSCAPE_SPKAC_free
-    NETSCAPE_SPKAC_new
-    NETSCAPE_SPKI_b64_decode
-    NETSCAPE_SPKI_b64_encode
-    NETSCAPE_SPKI_free
-    NETSCAPE_SPKI_get_pubkey
-    NETSCAPE_SPKI_new
-    NETSCAPE_SPKI_print
-    NETSCAPE_SPKI_set_pubkey
-    NETSCAPE_SPKI_sign
-    NETSCAPE_SPKI_verify
-    NETSCAPE_X509_free
-    NETSCAPE_X509_new
-    NOTICEREF_free
-    NOTICEREF_new
-    OBJ_add_object
-    OBJ_add_sigid
-    OBJ_bsearch_
-    OBJ_bsearch_ex_
-    OBJ_cleanup
-    OBJ_cmp
-    OBJ_create
-    OBJ_create_objects
-    OBJ_dup
-    OBJ_find_sigid_algs
-    OBJ_find_sigid_by_algs
-    OBJ_ln2nid
-    OBJ_NAME_add
-    OBJ_NAME_cleanup
-    OBJ_NAME_do_all
-    OBJ_NAME_do_all_sorted
-    OBJ_NAME_get
-    OBJ_NAME_init
-    OBJ_NAME_new_index
-    OBJ_NAME_remove
-    OBJ_new_nid
-    OBJ_nid2ln
-    OBJ_nid2obj
-    OBJ_nid2sn
-    OBJ_obj2nid
-    OBJ_obj2txt
-    OBJ_sigid_free
-    OBJ_sn2nid
-    OBJ_txt2nid
-    OBJ_txt2obj
-    OCSP_accept_responses_new
-    OCSP_archive_cutoff_new
-    OCSP_basic_add1_cert
-    OCSP_basic_add1_nonce
-    OCSP_basic_add1_status
-    OCSP_basic_sign
-    OCSP_basic_verify
-    OCSP_BASICRESP_add_ext
-    OCSP_BASICRESP_add1_ext_i2d
-    OCSP_BASICRESP_delete_ext
-    OCSP_BASICRESP_free
-    OCSP_BASICRESP_get_ext
-    OCSP_BASICRESP_get_ext_by_critical
-    OCSP_BASICRESP_get_ext_by_NID
-    OCSP_BASICRESP_get_ext_by_OBJ
-    OCSP_BASICRESP_get_ext_count
-    OCSP_BASICRESP_get1_ext_d2i
-    OCSP_BASICRESP_new
-    OCSP_cert_id_new
-    OCSP_cert_status_str
-    OCSP_cert_to_id
-    OCSP_CERTID_dup
-    OCSP_CERTID_free
-    OCSP_CERTID_new
-    OCSP_CERTSTATUS_free
-    OCSP_CERTSTATUS_new
-    OCSP_check_nonce
-    OCSP_check_validity
-    OCSP_copy_nonce
-    OCSP_crl_reason_str
-    OCSP_CRLID_free
-    OCSP_CRLID_new
-    OCSP_crlID_new
-    OCSP_id_cmp
-    OCSP_id_get0_info
-    OCSP_id_issuer_cmp
-    OCSP_ONEREQ_add_ext
-    OCSP_ONEREQ_add1_ext_i2d
-    OCSP_ONEREQ_delete_ext
-    OCSP_ONEREQ_free
-    OCSP_ONEREQ_get_ext
-    OCSP_ONEREQ_get_ext_by_critical
-    OCSP_ONEREQ_get_ext_by_NID
-    OCSP_ONEREQ_get_ext_by_OBJ
-    OCSP_ONEREQ_get_ext_count
-    OCSP_onereq_get0_id
-    OCSP_ONEREQ_get1_ext_d2i
-    OCSP_ONEREQ_new
-    OCSP_parse_url
-    OCSP_REQ_CTX_add1_header
-    OCSP_REQ_CTX_free
-    OCSP_REQ_CTX_set1_req
-    OCSP_REQINFO_free
-    OCSP_REQINFO_new
-    OCSP_REQUEST_add_ext
-    OCSP_request_add0_id
-    OCSP_request_add1_cert
-    OCSP_REQUEST_add1_ext_i2d
-    OCSP_request_add1_nonce
-    OCSP_REQUEST_delete_ext
-    OCSP_REQUEST_free
-    OCSP_REQUEST_get_ext
-    OCSP_REQUEST_get_ext_by_critical
-    OCSP_REQUEST_get_ext_by_NID
-    OCSP_REQUEST_get_ext_by_OBJ
-    OCSP_REQUEST_get_ext_count
-    OCSP_REQUEST_get1_ext_d2i
-    OCSP_request_is_signed
-    OCSP_REQUEST_new
-    OCSP_request_onereq_count
-    OCSP_request_onereq_get0
-    OCSP_REQUEST_print
-    OCSP_request_set1_name
-    OCSP_request_sign
-    OCSP_request_verify
-    OCSP_resp_count
-    OCSP_resp_find
-    OCSP_resp_find_status
-    OCSP_resp_get0
-    OCSP_RESPBYTES_free
-    OCSP_RESPBYTES_new
-    OCSP_RESPDATA_free
-    OCSP_RESPDATA_new
-    OCSP_RESPID_free
-    OCSP_RESPID_new
-    OCSP_response_create
-    OCSP_RESPONSE_free
-    OCSP_response_get1_basic
-    OCSP_RESPONSE_new
-    OCSP_RESPONSE_print
-    OCSP_response_status
-    OCSP_response_status_str
-    OCSP_REVOKEDINFO_free
-    OCSP_REVOKEDINFO_new
-    OCSP_sendreq_bio
-    OCSP_sendreq_nbio
-    OCSP_sendreq_new
-    OCSP_SERVICELOC_free
-    OCSP_SERVICELOC_new
-    OCSP_SIGNATURE_free
-    OCSP_SIGNATURE_new
-    OCSP_single_get0_status
-    OCSP_SINGLERESP_add_ext
-    OCSP_SINGLERESP_add1_ext_i2d
-    OCSP_SINGLERESP_delete_ext
-    OCSP_SINGLERESP_free
-    OCSP_SINGLERESP_get_ext
-    OCSP_SINGLERESP_get_ext_by_critical
-    OCSP_SINGLERESP_get_ext_by_NID
-    OCSP_SINGLERESP_get_ext_by_OBJ
-    OCSP_SINGLERESP_get_ext_count
-    OCSP_SINGLERESP_get1_ext_d2i
-    OCSP_SINGLERESP_new
-    OCSP_url_svcloc_new
-    OPENSSL_add_all_algorithms_conf
-    OPENSSL_add_all_algorithms_noconf
-    OpenSSL_add_all_ciphers
-    OpenSSL_add_all_digests
-    OPENSSL_asc2uni
-    OPENSSL_cleanse
-    OPENSSL_config
-    OPENSSL_cpuid_setup
-    OPENSSL_DIR_end
-    OPENSSL_DIR_read
-    OPENSSL_gmtime
-    OPENSSL_gmtime_adj
-    OPENSSL_ia32cap_loc
-    OPENSSL_init
-    OPENSSL_isservice
-    OPENSSL_issetugid
-    OPENSSL_load_builtin_modules
-    OPENSSL_memcmp
-    OPENSSL_no_config
-    OPENSSL_showfatal
-    OPENSSL_stderr
-    OPENSSL_strcasecmp
-    OPENSSL_strncasecmp
-    OPENSSL_uni2asc
-    OpenSSLDie
-    OTHERNAME_cmp
-    OTHERNAME_free
-    OTHERNAME_new
-    PBE2PARAM_free
-    PBE2PARAM_new
-    PBEPARAM_free
-    PBEPARAM_new
-    PBKDF2PARAM_free
-    PBKDF2PARAM_new
-    PEM_ASN1_read
-    PEM_ASN1_read_bio
-    PEM_ASN1_write
-    PEM_ASN1_write_bio
-    PEM_bytes_read_bio
-    pem_check_suffix
-    PEM_def_callback
-    PEM_dek_info
-    PEM_do_header
-    PEM_get_EVP_CIPHER_INFO
-    PEM_proc_type
-    PEM_read
-    PEM_read_bio
-    PEM_read_bio_CMS
-    PEM_read_bio_DHparams
-    PEM_read_bio_NETSCAPE_CERT_SEQUENCE
-    PEM_read_bio_Parameters
-    PEM_read_bio_PKCS7
-    PEM_read_bio_PKCS8
-    PEM_read_bio_PKCS8_PRIV_KEY_INFO
-    PEM_read_bio_PrivateKey
-    PEM_read_bio_PUBKEY
-    PEM_read_bio_RSA_PUBKEY
-    PEM_read_bio_RSAPrivateKey
-    PEM_read_bio_RSAPublicKey
-    PEM_read_bio_X509
-    PEM_read_bio_X509_AUX
-    PEM_read_bio_X509_CERT_PAIR
-    PEM_read_bio_X509_CRL
-    PEM_read_bio_X509_REQ
-    PEM_read_CMS
-    PEM_read_DHparams
-    PEM_read_NETSCAPE_CERT_SEQUENCE
-    PEM_read_PKCS7
-    PEM_read_PKCS8
-    PEM_read_PKCS8_PRIV_KEY_INFO
-    PEM_read_PrivateKey
-    PEM_read_PUBKEY
-    PEM_read_RSA_PUBKEY
-    PEM_read_RSAPrivateKey
-    PEM_read_RSAPublicKey
-    PEM_read_X509
-    PEM_read_X509_AUX
-    PEM_read_X509_CERT_PAIR
-    PEM_read_X509_CRL
-    PEM_read_X509_REQ
-    PEM_SealFinal
-    PEM_SealInit
-    PEM_SealUpdate
-    PEM_SignFinal
-    PEM_SignInit
-    PEM_SignUpdate
-    PEM_write
-    PEM_write_bio
-    PEM_write_bio_ASN1_stream
-    PEM_write_bio_CMS
-    PEM_write_bio_CMS_stream
-    PEM_write_bio_DHparams
-    PEM_write_bio_NETSCAPE_CERT_SEQUENCE
-    PEM_write_bio_Parameters
-    PEM_write_bio_PKCS7
-    PEM_write_bio_PKCS7_stream
-    PEM_write_bio_PKCS8
-    PEM_write_bio_PKCS8_PRIV_KEY_INFO
-    PEM_write_bio_PKCS8PrivateKey
-    PEM_write_bio_PKCS8PrivateKey_nid
-    PEM_write_bio_PrivateKey
-    PEM_write_bio_PUBKEY
-    PEM_write_bio_RSA_PUBKEY
-    PEM_write_bio_RSAPrivateKey
-    PEM_write_bio_RSAPublicKey
-    PEM_write_bio_X509
-    PEM_write_bio_X509_AUX
-    PEM_write_bio_X509_CERT_PAIR
-    PEM_write_bio_X509_CRL
-    PEM_write_bio_X509_REQ
-    PEM_write_bio_X509_REQ_NEW
-    PEM_write_CMS
-    PEM_write_DHparams
-    PEM_write_NETSCAPE_CERT_SEQUENCE
-    PEM_write_PKCS7
-    PEM_write_PKCS8
-    PEM_write_PKCS8_PRIV_KEY_INFO
-    PEM_write_PKCS8PrivateKey
-    PEM_write_PKCS8PrivateKey_nid
-    PEM_write_PrivateKey
-    PEM_write_PUBKEY
-    PEM_write_RSA_PUBKEY
-    PEM_write_RSAPrivateKey
-    PEM_write_RSAPublicKey
-    PEM_write_X509
-    PEM_write_X509_AUX
-    PEM_write_X509_CERT_PAIR
-    PEM_write_X509_CRL
-    PEM_write_X509_REQ
-    PEM_write_X509_REQ_NEW
-    PEM_X509_INFO_read
-    PEM_X509_INFO_read_bio
-    PEM_X509_INFO_write_bio
-    pitem_free
-    pitem_new
-    PKCS1_MGF1
-    PKCS12_add_cert
-    PKCS12_add_CSPName_asc
-    PKCS12_add_friendlyname_asc
-    PKCS12_add_friendlyname_uni
-    PKCS12_add_key
-    PKCS12_add_localkeyid
-    PKCS12_add_safe
-    PKCS12_add_safes
-    PKCS12_BAGS_free
-    PKCS12_BAGS_new
-    PKCS12_certbag2x509
-    PKCS12_certbag2x509crl
-    PKCS12_create
-    PKCS12_decrypt_skey
-    PKCS12_free
-    PKCS12_gen_mac
-    PKCS12_get_attr_gen
-    PKCS12_get_friendlyname
-    PKCS12_init
-    PKCS12_item_decrypt_d2i
-    PKCS12_item_i2d_encrypt
-    PKCS12_item_pack_safebag
-    PKCS12_key_gen_asc
-    PKCS12_key_gen_uni
-    PKCS12_MAC_DATA_free
-    PKCS12_MAC_DATA_new
-    PKCS12_MAKE_KEYBAG
-    PKCS12_MAKE_SHKEYBAG
-    PKCS12_new
-    PKCS12_newpass
-    PKCS12_pack_authsafes
-    PKCS12_pack_p7data
-    PKCS12_pack_p7encdata
-    PKCS12_parse
-    PKCS12_PBE_add
-    PKCS12_pbe_crypt
-    PKCS12_PBE_keyivgen
-    PKCS12_SAFEBAG_free
-    PKCS12_SAFEBAG_new
-    PKCS12_set_mac
-    PKCS12_setup_mac
-    PKCS12_unpack_authsafes
-    PKCS12_unpack_p7data
-    PKCS12_unpack_p7encdata
-    PKCS12_verify_mac
-    PKCS12_x5092certbag
-    PKCS12_x509crl2certbag
-    PKCS5_PBE_add
-    PKCS5_PBE_keyivgen
-    PKCS5_pbe_set
-    PKCS5_pbe_set0_algor
-    PKCS5_pbe2_set
-    PKCS5_pbe2_set_iv
-    PKCS5_PBKDF2_HMAC
-    PKCS5_PBKDF2_HMAC_SHA1
-    PKCS5_pbkdf2_set
-    PKCS5_v2_PBE_keyivgen
-    PKCS5_v2_PBKDF2_keyivgen
-    PKCS7_add_attrib_content_type
-    PKCS7_add_attrib_smimecap
-    PKCS7_add_attribute
-    PKCS7_add_certificate
-    PKCS7_add_crl
-    PKCS7_add_recipient
-    PKCS7_add_recipient_info
-    PKCS7_add_signature
-    PKCS7_add_signed_attribute
-    PKCS7_add_signer
-    PKCS7_add0_attrib_signing_time
-    PKCS7_add1_attrib_digest
-    PKCS7_cert_from_signer_info
-    PKCS7_content_new
-    PKCS7_ctrl
-    PKCS7_dataDecode
-    PKCS7_dataFinal
-    PKCS7_dataInit
-    PKCS7_dataVerify
-    PKCS7_decrypt
-    PKCS7_DIGEST_free
-    PKCS7_digest_from_attributes
-    PKCS7_DIGEST_new
-    PKCS7_dup
-    PKCS7_ENC_CONTENT_free
-    PKCS7_ENC_CONTENT_new
-    PKCS7_encrypt
-    PKCS7_ENCRYPT_free
-    PKCS7_ENCRYPT_new
-    PKCS7_ENVELOPE_free
-    PKCS7_ENVELOPE_new
-    PKCS7_final
-    PKCS7_free
-    PKCS7_get_attribute
-    PKCS7_get_issuer_and_serial
-    PKCS7_get_signed_attribute
-    PKCS7_get_signer_info
-    PKCS7_get_smimecap
-    PKCS7_get0_signers
-    PKCS7_ISSUER_AND_SERIAL_digest
-    PKCS7_ISSUER_AND_SERIAL_free
-    PKCS7_ISSUER_AND_SERIAL_new
-    PKCS7_new
-    PKCS7_print_ctx
-    PKCS7_RECIP_INFO_free
-    PKCS7_RECIP_INFO_get0_alg
-    PKCS7_RECIP_INFO_new
-    PKCS7_RECIP_INFO_set
-    PKCS7_set_attributes
-    PKCS7_set_cipher
-    PKCS7_set_content
-    PKCS7_set_digest
-    PKCS7_set_signed_attributes
-    PKCS7_set_type
-    PKCS7_set0_type_other
-    PKCS7_sign
-    PKCS7_sign_add_signer
-    PKCS7_SIGN_ENVELOPE_free
-    PKCS7_SIGN_ENVELOPE_new
-    PKCS7_signatureVerify
-    PKCS7_SIGNED_free
-    PKCS7_SIGNED_new
-    PKCS7_SIGNER_INFO_free
-    PKCS7_SIGNER_INFO_get0_algs
-    PKCS7_SIGNER_INFO_new
-    PKCS7_SIGNER_INFO_set
-    PKCS7_SIGNER_INFO_sign
-    PKCS7_simple_smimecap
-    PKCS7_stream
-    PKCS7_verify
-    PKCS8_add_keyusage
-    PKCS8_decrypt
-    PKCS8_encrypt
-    PKCS8_pkey_get0
-    PKCS8_pkey_set0
-    PKCS8_PRIV_KEY_INFO_free
-    PKCS8_PRIV_KEY_INFO_new
-    PKCS8_set_broken
-    PKEY_USAGE_PERIOD_free
-    PKEY_USAGE_PERIOD_new
-    policy_cache_find_data
-    policy_cache_free
-    policy_cache_set
-    policy_cache_set_mapping
-    POLICY_CONSTRAINTS_free
-    POLICY_CONSTRAINTS_new
-    policy_data_free
-    policy_data_new
-    POLICY_MAPPING_free
-    POLICY_MAPPING_new
-    policy_node_cmp_new
-    policy_node_free
-    policy_node_match
-    POLICYINFO_free
-    POLICYINFO_new
-    POLICYQUALINFO_free
-    POLICYQUALINFO_new
-    pqueue_find
-    pqueue_free
-    pqueue_insert
-    pqueue_iterator
-    pqueue_new
-    pqueue_next
-    pqueue_peek
-    pqueue_pop
-    pqueue_print
-    pqueue_size
-    private_AES_set_decrypt_key
-    private_AES_set_encrypt_key
-    private_RC4_set_key
-    PROXY_CERT_INFO_EXTENSION_free
-    PROXY_CERT_INFO_EXTENSION_new
-    PROXY_POLICY_free
-    PROXY_POLICY_new
-    RAND_add
-    RAND_bytes
-    RAND_cleanup
-    RAND_egd
-    RAND_egd_bytes
-    RAND_event
-    RAND_file_name
-    RAND_get_rand_method
-    RAND_load_file
-    RAND_poll
-    RAND_pseudo_bytes
-    RAND_query_egd_bytes
-    RAND_screen
-    RAND_seed
-    RAND_set_rand_method
-    RAND_SSLeay
-    RAND_status
-    RAND_write_file
-    RC4
-    RC4_options
-    RC4_set_key
-    RSA_blinding_off
-    RSA_blinding_on
-    RSA_check_key
-    RSA_flags
-    RSA_free
-    RSA_generate_key
-    RSA_generate_key_ex
-    RSA_get_default_method
-    RSA_get_ex_data
-    RSA_get_ex_new_index
-    RSA_get_method
-    RSA_memory_lock
-    RSA_new
-    RSA_new_method
-    RSA_null_method
-    RSA_padding_add_none
-    RSA_padding_add_PKCS1_OAEP
-    RSA_padding_add_PKCS1_PSS
-    RSA_padding_add_PKCS1_PSS_mgf1
-    RSA_padding_add_PKCS1_type_1
-    RSA_padding_add_PKCS1_type_2
-    RSA_padding_add_SSLv23
-    RSA_padding_add_X931
-    RSA_padding_check_none
-    RSA_padding_check_PKCS1_OAEP
-    RSA_padding_check_PKCS1_type_1
-    RSA_padding_check_PKCS1_type_2
-    RSA_padding_check_SSLv23
-    RSA_padding_check_X931
-    RSA_PKCS1_SSLeay
-    RSA_print
-    RSA_print_fp
-    RSA_private_decrypt
-    RSA_private_encrypt
-    RSA_PSS_PARAMS_free
-    RSA_PSS_PARAMS_new
-    RSA_public_decrypt
-    RSA_public_encrypt
-    RSA_set_default_method
-    RSA_set_ex_data
-    RSA_set_method
-    RSA_setup_blinding
-    RSA_sign
-    RSA_sign_ASN1_OCTET_STRING
-    RSA_size
-    RSA_up_ref
-    RSA_verify
-    RSA_verify_ASN1_OCTET_STRING
-    RSA_verify_PKCS1_PSS
-    RSA_verify_PKCS1_PSS_mgf1
-    RSA_X931_hash_id
-    RSAPrivateKey_dup
-    RSAPublicKey_dup
-    s2i_ASN1_INTEGER
-    s2i_ASN1_OCTET_STRING
-    SEED_cbc_encrypt
-    SEED_cfb128_encrypt
-    SEED_decrypt
-    SEED_ecb_encrypt
-    SEED_encrypt
-    SEED_ofb128_encrypt
-    SEED_set_key
-    SHA1
-    SHA1_Final
-    SHA1_Init
-    SHA1_Transform
-    SHA1_Update
-    SHA224
-    SHA224_Final
-    SHA224_Init
-    SHA224_Update
-    SHA256
-    SHA256_Final
-    SHA256_Init
-    SHA256_Transform
-    SHA256_Update
-    SHA384
-    SHA384_Final
-    SHA384_Init
-    SHA384_Update
-    SHA512
-    SHA512_Final
-    SHA512_Init
-    SHA512_Transform
-    SHA512_Update
-    sk_delete
-    sk_delete_ptr
-    sk_dup
-    sk_find
-    sk_find_ex
-    sk_free
-    sk_insert
-    sk_is_sorted
-    sk_new
-    sk_new_null
-    sk_num
-    sk_pop
-    sk_pop_free
-    sk_push
-    sk_set
-    sk_set_cmp_func
-    sk_shift
-    sk_sort
-    sk_unshift
-    sk_value
-    sk_zero
-    SMIME_crlf_copy
-    SMIME_read_ASN1
-    SMIME_read_CMS
-    SMIME_read_PKCS7
-    SMIME_text
-    SMIME_write_ASN1
-    SMIME_write_CMS
-    SMIME_write_PKCS7
-    SRP_Calc_A
-    SRP_Calc_B
-    SRP_Calc_client_key
-    SRP_Calc_server_key
-    SRP_Calc_u
-    SRP_Calc_x
-    SRP_check_known_gN_param
-    SRP_create_verifier
-    SRP_create_verifier_BN
-    SRP_get_default_gN
-    SRP_VBASE_free
-    SRP_VBASE_get_by_user
-    SRP_VBASE_init
-    SRP_VBASE_new
-    SRP_Verify_A_mod_N
-    SRP_Verify_B_mod_N
-    SSLeay
-    SSLeay_version
-    string_to_hex
-    SXNET_add_id_asc
-    SXNET_add_id_INTEGER
-    SXNET_add_id_ulong
-    SXNET_free
-    SXNET_get_id_asc
-    SXNET_get_id_INTEGER
-    SXNET_get_id_ulong
-    SXNET_new
-    SXNETID_free
-    SXNETID_new
-    tree_find_sk
-    TXT_DB_create_index
-    TXT_DB_free
-    TXT_DB_get_by_index
-    TXT_DB_insert
-    TXT_DB_read
-    TXT_DB_write
-    UI_add_error_string
-    UI_add_info_string
-    UI_add_input_boolean
-    UI_add_input_string
-    UI_add_user_data
-    UI_add_verify_string
-    UI_construct_prompt
-    UI_create_method
-    UI_ctrl
-    UI_destroy_method
-    UI_dup_error_string
-    UI_dup_info_string
-    UI_dup_input_boolean
-    UI_dup_input_string
-    UI_dup_verify_string
-    UI_free
-    UI_get_default_method
-    UI_get_ex_data
-    UI_get_ex_new_index
-    UI_get_input_flags
-    UI_get_method
-    UI_get_result_maxsize
-    UI_get_result_minsize
-    UI_get_string_type
-    UI_get0_action_string
-    UI_get0_output_string
-    UI_get0_result
-    UI_get0_result_string
-    UI_get0_test_string
-    UI_get0_user_data
-    UI_method_get_closer
-    UI_method_get_flusher
-    UI_method_get_opener
-    UI_method_get_prompt_constructor
-    UI_method_get_reader
-    UI_method_get_writer
-    UI_method_set_closer
-    UI_method_set_flusher
-    UI_method_set_opener
-    UI_method_set_prompt_constructor
-    UI_method_set_reader
-    UI_method_set_writer
-    UI_new
-    UI_new_method
-    UI_OpenSSL
-    UI_process
-    UI_set_default_method
-    UI_set_ex_data
-    UI_set_method
-    UI_set_result
-    UI_UTIL_read_pw
-    UI_UTIL_read_pw_string
-    USERNOTICE_free
-    USERNOTICE_new
-    UTF8_getc
-    UTF8_putc
-    v2i_ASN1_BIT_STRING
-    v2i_GENERAL_NAME
-    v2i_GENERAL_NAME_ex
-    v2i_GENERAL_NAMES
-    X509_add_ext
-    X509_add1_ext_i2d
-    X509_add1_reject_object
-    X509_add1_trust_object
-    X509_ALGOR_dup
-    X509_ALGOR_free
-    X509_ALGOR_get0
-    X509_ALGOR_new
-    X509_ALGOR_set_md
-    X509_ALGOR_set0
-    X509_alias_get0
-    X509_alias_set1
-    X509_ATTRIBUTE_count
-    X509_ATTRIBUTE_create
-    X509_ATTRIBUTE_create_by_NID
-    X509_ATTRIBUTE_create_by_OBJ
-    X509_ATTRIBUTE_create_by_txt
-    X509_ATTRIBUTE_dup
-    X509_ATTRIBUTE_free
-    X509_ATTRIBUTE_get0_data
-    X509_ATTRIBUTE_get0_object
-    X509_ATTRIBUTE_get0_type
-    X509_ATTRIBUTE_new
-    X509_ATTRIBUTE_set1_data
-    X509_ATTRIBUTE_set1_object
-    X509_CERT_AUX_free
-    X509_CERT_AUX_new
-    X509_CERT_AUX_print
-    X509_CERT_PAIR_free
-    X509_CERT_PAIR_new
-    X509_certificate_type
-    X509_check_akid
-    X509_check_ca
-    X509_check_issued
-    X509_check_private_key
-    X509_check_purpose
-    X509_check_trust
-    X509_CINF_free
-    X509_CINF_new
-    X509_cmp
-    X509_cmp_current_time
-    X509_cmp_time
-    X509_CRL_add_ext
-    X509_CRL_add0_revoked
-    X509_CRL_add1_ext_i2d
-    X509_CRL_cmp
-    X509_CRL_delete_ext
-    X509_CRL_digest
-    X509_CRL_dup
-    X509_CRL_free
-    X509_CRL_get_ext
-    X509_CRL_get_ext_by_critical
-    X509_CRL_get_ext_by_NID
-    X509_CRL_get_ext_by_OBJ
-    X509_CRL_get_ext_count
-    X509_CRL_get_ext_d2i
-    X509_CRL_get_meth_data
-    X509_CRL_get0_by_cert
-    X509_CRL_get0_by_serial
-    X509_CRL_INFO_free
-    X509_CRL_INFO_new
-    X509_CRL_match
-    X509_CRL_METHOD_free
-    X509_CRL_METHOD_new
-    X509_CRL_new
-    X509_CRL_print
-    X509_CRL_print_fp
-    X509_CRL_set_default_method
-    X509_CRL_set_issuer_name
-    X509_CRL_set_lastUpdate
-    X509_CRL_set_meth_data
-    X509_CRL_set_nextUpdate
-    X509_CRL_set_version
-    X509_CRL_sign
-    X509_CRL_sign_ctx
-    X509_CRL_sort
-    X509_CRL_verify
-    X509_delete_ext
-    X509_digest
-    X509_dup
-    X509_email_free
-    X509_EXTENSION_create_by_NID
-    X509_EXTENSION_create_by_OBJ
-    X509_EXTENSION_dup
-    X509_EXTENSION_free
-    X509_EXTENSION_get_critical
-    X509_EXTENSION_get_data
-    X509_EXTENSION_get_object
-    X509_EXTENSION_new
-    X509_EXTENSION_set_critical
-    X509_EXTENSION_set_data
-    X509_EXTENSION_set_object
-    X509_find_by_issuer_and_serial
-    X509_find_by_subject
-    X509_free
-    X509_get_default_cert_area
-    X509_get_default_cert_dir
-    X509_get_default_cert_dir_env
-    X509_get_default_cert_file
-    X509_get_default_cert_file_env
-    X509_get_default_private_dir
-    X509_get_ex_data
-    X509_get_ex_new_index
-    X509_get_ext
-    X509_get_ext_by_critical
-    X509_get_ext_by_NID
-    X509_get_ext_by_OBJ
-    X509_get_ext_count
-    X509_get_ext_d2i
-    X509_get_issuer_name
-    X509_get_pubkey
-    X509_get_pubkey_parameters
-    X509_get_serialNumber
-    X509_get_subject_name
-    X509_get0_pubkey_bitstr
-    X509_get1_email
-    X509_get1_ocsp
-    X509_gmtime_adj
-    X509_INFO_free
-    X509_INFO_new
-    X509_issuer_and_serial_cmp
-    X509_issuer_and_serial_hash
-    X509_issuer_name_cmp
-    X509_issuer_name_hash
-    X509_issuer_name_hash_old
-    X509_keyid_get0
-    X509_keyid_set1
-    X509_load_cert_crl_file
-    X509_load_cert_file
-    X509_load_crl_file
-    X509_LOOKUP_by_alias
-    X509_LOOKUP_by_fingerprint
-    X509_LOOKUP_by_issuer_serial
-    X509_LOOKUP_by_subject
-    X509_LOOKUP_ctrl
-    X509_LOOKUP_file
-    X509_LOOKUP_free
-    X509_LOOKUP_hash_dir
-    X509_LOOKUP_init
-    X509_LOOKUP_new
-    X509_LOOKUP_shutdown
-    X509_NAME_add_entry
-    X509_NAME_add_entry_by_NID
-    X509_NAME_add_entry_by_OBJ
-    X509_NAME_add_entry_by_txt
-    X509_NAME_cmp
-    X509_NAME_delete_entry
-    X509_NAME_digest
-    X509_NAME_dup
-    X509_NAME_entry_count
-    X509_NAME_ENTRY_create_by_NID
-    X509_NAME_ENTRY_create_by_OBJ
-    X509_NAME_ENTRY_create_by_txt
-    X509_NAME_ENTRY_dup
-    X509_NAME_ENTRY_free
-    X509_NAME_ENTRY_get_data
-    X509_NAME_ENTRY_get_object
-    X509_NAME_ENTRY_new
-    X509_NAME_ENTRY_set_data
-    X509_NAME_ENTRY_set_object
-    X509_NAME_free
-    X509_NAME_get_entry
-    X509_NAME_get_index_by_NID
-    X509_NAME_get_index_by_OBJ
-    X509_NAME_get_text_by_NID
-    X509_NAME_get_text_by_OBJ
-    X509_NAME_hash
-    X509_NAME_hash_old
-    X509_NAME_new
-    X509_NAME_oneline
-    X509_NAME_print
-    X509_NAME_print_ex
-    X509_NAME_print_ex_fp
-    X509_NAME_set
-    X509_new
-    X509_OBJECT_free_contents
-    X509_OBJECT_idx_by_subject
-    X509_OBJECT_retrieve_by_subject
-    X509_OBJECT_retrieve_match
-    X509_OBJECT_up_ref_count
-    X509_ocspid_print
-    X509_PKEY_free
-    X509_PKEY_new
-    X509_policy_check
-    X509_policy_level_get0_node
-    X509_policy_level_node_count
-    X509_policy_node_get0_parent
-    X509_policy_node_get0_policy
-    X509_policy_node_get0_qualifiers
-    X509_POLICY_NODE_print
-    X509_policy_tree_free
-    X509_policy_tree_get0_level
-    X509_policy_tree_get0_policies
-    X509_policy_tree_get0_user_policies
-    X509_policy_tree_level_count
-    X509_print
-    X509_print_ex
-    X509_print_ex_fp
-    X509_print_fp
-    X509_pubkey_digest
-    X509_PUBKEY_free
-    X509_PUBKEY_get
-    X509_PUBKEY_get0_param
-    X509_PUBKEY_new
-    X509_PUBKEY_set
-    X509_PUBKEY_set0_param
-    X509_PURPOSE_add
-    X509_PURPOSE_cleanup
-    X509_PURPOSE_get_by_id
-    X509_PURPOSE_get_by_sname
-    X509_PURPOSE_get_count
-    X509_PURPOSE_get_id
-    X509_PURPOSE_get_trust
-    X509_PURPOSE_get0
-    X509_PURPOSE_get0_name
-    X509_PURPOSE_get0_sname
-    X509_PURPOSE_set
-    X509_reject_clear
-    X509_REQ_add_extensions
-    X509_REQ_add_extensions_nid
-    X509_REQ_add1_attr
-    X509_REQ_add1_attr_by_NID
-    X509_REQ_add1_attr_by_OBJ
-    X509_REQ_add1_attr_by_txt
-    X509_REQ_check_private_key
-    X509_REQ_delete_attr
-    X509_REQ_digest
-    X509_REQ_dup
-    X509_REQ_extension_nid
-    X509_REQ_free
-    X509_REQ_get_attr
-    X509_REQ_get_attr_by_NID
-    X509_REQ_get_attr_by_OBJ
-    X509_REQ_get_attr_count
-    X509_REQ_get_extension_nids
-    X509_REQ_get_extensions
-    X509_REQ_get_pubkey
-    X509_REQ_get1_email
-    X509_REQ_INFO_free
-    X509_REQ_INFO_new
-    X509_REQ_new
-    X509_REQ_print
-    X509_REQ_print_ex
-    X509_REQ_print_fp
-    X509_REQ_set_extension_nids
-    X509_REQ_set_pubkey
-    X509_REQ_set_subject_name
-    X509_REQ_set_version
-    X509_REQ_sign
-    X509_REQ_sign_ctx
-    X509_REQ_to_X509
-    X509_REQ_verify
-    X509_REVOKED_add_ext
-    X509_REVOKED_add1_ext_i2d
-    X509_REVOKED_delete_ext
-    X509_REVOKED_free
-    X509_REVOKED_get_ext
-    X509_REVOKED_get_ext_by_critical
-    X509_REVOKED_get_ext_by_NID
-    X509_REVOKED_get_ext_by_OBJ
-    X509_REVOKED_get_ext_count
-    X509_REVOKED_get_ext_d2i
-    X509_REVOKED_new
-    X509_REVOKED_set_revocationDate
-    X509_REVOKED_set_serialNumber
-    X509_set_ex_data
-    X509_set_issuer_name
-    X509_set_notAfter
-    X509_set_notBefore
-    X509_set_pubkey
-    X509_set_serialNumber
-    X509_set_subject_name
-    X509_set_version
-    X509_SIG_free
-    X509_SIG_new
-    X509_sign
-    X509_sign_ctx
-    X509_signature_dump
-    X509_signature_print
-    X509_STORE_add_cert
-    X509_STORE_add_crl
-    X509_STORE_add_lookup
-    X509_STORE_CTX_cleanup
-    X509_STORE_CTX_free
-    X509_STORE_CTX_get_chain
-    X509_STORE_CTX_get_current_cert
-    X509_STORE_CTX_get_error
-    X509_STORE_CTX_get_error_depth
-    X509_STORE_CTX_get_ex_data
-    X509_STORE_CTX_get_ex_new_index
-    X509_STORE_CTX_get_explicit_policy
-    X509_STORE_CTX_get0_current_crl
-    X509_STORE_CTX_get0_current_issuer
-    X509_STORE_CTX_get0_param
-    X509_STORE_CTX_get0_parent_ctx
-    X509_STORE_CTX_get0_policy_tree
-    X509_STORE_CTX_get1_chain
-    X509_STORE_CTX_get1_issuer
-    X509_STORE_CTX_init
-    X509_STORE_CTX_new
-    X509_STORE_CTX_purpose_inherit
-    X509_STORE_CTX_set_cert
-    X509_STORE_CTX_set_chain
-    X509_STORE_CTX_set_default
-    X509_STORE_CTX_set_depth
-    X509_STORE_CTX_set_error
-    X509_STORE_CTX_set_ex_data
-    X509_STORE_CTX_set_flags
-    X509_STORE_CTX_set_purpose
-    X509_STORE_CTX_set_time
-    X509_STORE_CTX_set_trust
-    X509_STORE_CTX_set_verify_cb
-    X509_STORE_CTX_set0_crls
-    X509_STORE_CTX_set0_param
-    X509_STORE_CTX_trusted_stack
-    X509_STORE_free
-    X509_STORE_get_by_subject
-    X509_STORE_get1_certs
-    X509_STORE_get1_crls
-    X509_STORE_load_locations
-    X509_STORE_new
-    X509_STORE_set_default_paths
-    X509_STORE_set_depth
-    X509_STORE_set_flags
-    X509_STORE_set_purpose
-    X509_STORE_set_trust
-    X509_STORE_set_verify_cb
-    X509_STORE_set1_param
-    X509_subject_name_cmp
-    X509_subject_name_hash
-    X509_subject_name_hash_old
-    X509_supported_extension
-    X509_time_adj
-    X509_time_adj_ex
-    X509_to_X509_REQ
-    X509_TRUST_add
-    X509_TRUST_cleanup
-    X509_trust_clear
-    X509_TRUST_get_by_id
-    X509_TRUST_get_count
-    X509_TRUST_get_flags
-    X509_TRUST_get_trust
-    X509_TRUST_get0
-    X509_TRUST_get0_name
-    X509_TRUST_set
-    X509_TRUST_set_default
-    X509_VAL_free
-    X509_VAL_new
-    X509_verify
-    X509_verify_cert
-    X509_verify_cert_error_string
-    X509_VERIFY_PARAM_add0_policy
-    X509_VERIFY_PARAM_add0_table
-    X509_VERIFY_PARAM_clear_flags
-    X509_VERIFY_PARAM_free
-    X509_VERIFY_PARAM_get_depth
-    X509_VERIFY_PARAM_get_flags
-    X509_VERIFY_PARAM_inherit
-    X509_VERIFY_PARAM_lookup
-    X509_VERIFY_PARAM_new
-    X509_VERIFY_PARAM_set_depth
-    X509_VERIFY_PARAM_set_flags
-    X509_VERIFY_PARAM_set_purpose
-    X509_VERIFY_PARAM_set_time
-    X509_VERIFY_PARAM_set_trust
-    X509_VERIFY_PARAM_set1
-    X509_VERIFY_PARAM_set1_name
-    X509_VERIFY_PARAM_set1_policies
-    X509_VERIFY_PARAM_table_cleanup
-    X509at_add1_attr
-    X509at_add1_attr_by_NID
-    X509at_add1_attr_by_OBJ
-    X509at_add1_attr_by_txt
-    X509at_delete_attr
-    X509at_get_attr
-    X509at_get_attr_by_NID
-    X509at_get_attr_by_OBJ
-    X509at_get_attr_count
-    X509at_get0_data_by_OBJ
-    X509v3_add_ext
-    X509V3_add_standard_extensions
-    X509V3_add_value
-    X509V3_add_value_bool
-    X509V3_add_value_bool_nf
-    X509V3_add_value_int
-    X509V3_add_value_uchar
-    X509V3_add1_i2d
-    X509V3_conf_free
-    X509v3_delete_ext
-    X509V3_EXT_add
-    X509V3_EXT_add_alias
-    X509V3_EXT_add_conf
-    X509V3_EXT_add_list
-    X509V3_EXT_add_nconf
-    X509V3_EXT_add_nconf_sk
-    X509V3_EXT_cleanup
-    X509V3_EXT_conf
-    X509V3_EXT_conf_nid
-    X509V3_EXT_CRL_add_conf
-    X509V3_EXT_CRL_add_nconf
-    X509V3_EXT_d2i
-    X509V3_EXT_get
-    X509V3_EXT_get_nid
-    X509V3_EXT_i2d
-    X509V3_EXT_nconf
-    X509V3_EXT_nconf_nid
-    X509V3_EXT_print
-    X509V3_EXT_print_fp
-    X509V3_EXT_REQ_add_conf
-    X509V3_EXT_REQ_add_nconf
-    X509V3_EXT_val_prn
-    X509V3_extensions_print
-    X509V3_get_d2i
-    X509v3_get_ext
-    X509v3_get_ext_by_critical
-    X509v3_get_ext_by_NID
-    X509v3_get_ext_by_OBJ
-    X509v3_get_ext_count
-    X509V3_get_section
-    X509V3_get_string
-    X509V3_get_value_bool
-    X509V3_get_value_int
-    X509V3_NAME_from_section
-    X509V3_parse_list
-    X509V3_section_free
-    X509V3_set_conf_lhash
-    X509V3_set_ctx
-    X509V3_set_nconf
-    X509V3_string_free
-
-    ;
-    ; OpenSSL ssl symbols
-    ;
-    BIO_f_ssl
-    BIO_new_buffer_ssl_connect
-    BIO_new_ssl
-    BIO_new_ssl_connect
-    BIO_ssl_copy_session_id
-    BIO_ssl_shutdown
-    d2i_SSL_SESSION
-    do_dtls1_write
-    dtls1_accept
-    dtls1_buffer_message
-    dtls1_check_timeout_num
-    dtls1_clear
-    dtls1_clear_record_buffer
-    dtls1_client_hello
-    dtls1_connect
-    dtls1_ctrl
-    dtls1_default_timeout
-    dtls1_dispatch_alert
-    dtls1_do_write
-    dtls1_double_timeout
-    dtls1_enc
-    dtls1_free
-    dtls1_get_ccs_header
-    dtls1_get_cipher
-    dtls1_get_message
-    dtls1_get_message_header
-    dtls1_get_queue_priority
-    dtls1_get_record
-    dtls1_get_timeout
-    dtls1_handle_timeout
-    dtls1_heartbeat
-    dtls1_is_timer_expired
-    dtls1_listen
-    dtls1_min_mtu
-    dtls1_new
-    dtls1_output_cert_chain
-    dtls1_process_heartbeat
-    dtls1_read_bytes
-    dtls1_read_failed
-    dtls1_reset_seq_numbers
-    dtls1_retransmit_buffered_messages
-    dtls1_retransmit_message
-    dtls1_send_certificate_request
-    dtls1_send_change_cipher_spec
-    dtls1_send_client_certificate
-    dtls1_send_client_key_exchange
-    dtls1_send_client_verify
-    dtls1_send_finished
-    dtls1_send_hello_request
-    dtls1_send_newsession_ticket
-    dtls1_send_server_certificate
-    dtls1_send_server_done
-    dtls1_send_server_hello
-    dtls1_send_server_key_exchange
-    dtls1_set_message_header
-    dtls1_shutdown
-    dtls1_start_timer
-    dtls1_stop_timer
-    dtls1_write_app_data_bytes
-    dtls1_write_bytes
-    DTLSv1_client_method
-    DTLSv1_method
-    DTLSv1_server_method
-    ERR_load_SSL_strings
-    i2d_SSL_SESSION
-    n_ssl3_mac
-    OBJ_bsearch_ssl_cipher_id
-    PEM_read_bio_SSL_SESSION
-    PEM_read_SSL_SESSION
-    PEM_write_bio_SSL_SESSION
-    PEM_write_SSL_SESSION
-    SRP_Calc_A_param
-    SRP_generate_client_master_secret
-    SRP_generate_server_master_secret
-    SSL_accept
-    SSL_add_client_CA
-    ssl_add_clienthello_renegotiate_ext
-    ssl_add_clienthello_tlsext
-    ssl_add_clienthello_use_srtp_ext
-    SSL_add_dir_cert_subjects_to_stack
-    SSL_add_file_cert_subjects_to_stack
-    ssl_add_serverhello_renegotiate_ext
-    ssl_add_serverhello_tlsext
-    ssl_add_serverhello_use_srtp_ext
-    SSL_alert_desc_string
-    SSL_alert_desc_string_long
-    SSL_alert_type_string
-    SSL_alert_type_string_long
-    ssl_bad_method
-    ssl_bytes_to_cipher_list
-    SSL_cache_hit
-    SSL_callback_ctrl
-    ssl_cert_dup
-    ssl_cert_free
-    ssl_cert_inst
-    ssl_cert_new
-    ssl_cert_type
-    ssl_check_clienthello_tlsext_early
-    ssl_check_clienthello_tlsext_late
-    SSL_check_private_key
-    ssl_check_serverhello_tlsext
-    SSL_CIPHER_description
-    SSL_CIPHER_get_bits
-    ssl_cipher_get_evp
-    SSL_CIPHER_get_id
-    SSL_CIPHER_get_name
-    SSL_CIPHER_get_version
-    ssl_cipher_id_cmp
-    ssl_cipher_list_to_bytes
-    ssl_cipher_ptr_id_cmp
-    SSL_clear
-    ssl_clear_bad_session
-    ssl_clear_cipher_ctx
-    ssl_clear_hash_ctx
-    SSL_COMP_add_compression_method
-    SSL_COMP_get_compression_methods
-    SSL_COMP_get_name
-    SSL_connect
-    SSL_copy_session_id
-    ssl_create_cipher_list
-    SSL_ctrl
-    SSL_CTX_add_client_CA
-    SSL_CTX_add_session
-    SSL_CTX_callback_ctrl
-    SSL_CTX_check_private_key
-    SSL_CTX_ctrl
-    SSL_CTX_flush_sessions
-    SSL_CTX_free
-    SSL_CTX_get_cert_store
-    SSL_CTX_get_client_CA_list
-    SSL_CTX_get_client_cert_cb
-    SSL_CTX_get_ex_data
-    SSL_CTX_get_ex_new_index
-    SSL_CTX_get_info_callback
-    SSL_CTX_get_quiet_shutdown
-    SSL_CTX_get_timeout
-    SSL_CTX_get_verify_callback
-    SSL_CTX_get_verify_depth
-    SSL_CTX_get_verify_mode
-    SSL_CTX_load_verify_locations
-    SSL_CTX_new
-    SSL_CTX_remove_session
-    SSL_CTX_sess_get_get_cb
-    SSL_CTX_sess_get_new_cb
-    SSL_CTX_sess_get_remove_cb
-    SSL_CTX_sess_set_get_cb
-    SSL_CTX_sess_set_new_cb
-    SSL_CTX_sess_set_remove_cb
-    SSL_CTX_sessions
-    SSL_CTX_set_cert_store
-    SSL_CTX_set_cert_verify_callback
-    SSL_CTX_set_cipher_list
-    SSL_CTX_set_client_CA_list
-    SSL_CTX_set_client_cert_cb
-    SSL_CTX_set_cookie_generate_cb
-    SSL_CTX_set_cookie_verify_cb
-    SSL_CTX_set_default_passwd_cb
-    SSL_CTX_set_default_passwd_cb_userdata
-    SSL_CTX_set_default_verify_paths
-    SSL_CTX_set_ex_data
-    SSL_CTX_set_generate_session_id
-    SSL_CTX_set_info_callback
-    SSL_CTX_set_msg_callback
-    SSL_CTX_set_next_proto_select_cb
-    SSL_CTX_set_next_protos_advertised_cb
-    SSL_CTX_set_psk_client_callback
-    SSL_CTX_set_psk_server_callback
-    SSL_CTX_set_purpose
-    SSL_CTX_set_quiet_shutdown
-    SSL_CTX_set_session_id_context
-    SSL_CTX_set_srp_cb_arg
-    SSL_CTX_set_srp_client_pwd_callback
-    SSL_CTX_set_srp_password
-    SSL_CTX_set_srp_strength
-    SSL_CTX_set_srp_username
-    SSL_CTX_set_srp_username_callback
-    SSL_CTX_set_srp_verify_param_callback
-    SSL_CTX_set_ssl_version
-    SSL_CTX_set_timeout
-    SSL_CTX_set_tlsext_use_srtp
-    SSL_CTX_set_tmp_dh_callback
-    SSL_CTX_set_tmp_rsa_callback
-    SSL_CTX_set_trust
-    SSL_CTX_set_verify
-    SSL_CTX_set_verify_depth
-    SSL_CTX_set1_param
-    SSL_CTX_SRP_CTX_free
-    SSL_CTX_SRP_CTX_init
-    SSL_CTX_use_certificate
-    SSL_CTX_use_certificate_ASN1
-    SSL_CTX_use_certificate_chain_file
-    SSL_CTX_use_certificate_file
-    SSL_CTX_use_PrivateKey
-    SSL_CTX_use_PrivateKey_ASN1
-    SSL_CTX_use_PrivateKey_file
-    SSL_CTX_use_psk_identity_hint
-    SSL_CTX_use_RSAPrivateKey
-    SSL_CTX_use_RSAPrivateKey_ASN1
-    SSL_CTX_use_RSAPrivateKey_file
-    ssl_do_client_cert_cb
-    SSL_do_handshake
-    SSL_dup
-    SSL_dup_CA_list
-    SSL_export_keying_material
-    ssl_fill_hello_random
-    SSL_free
-    ssl_free_wbio_buffer
-    ssl_get_algorithm2
-    SSL_get_certificate
-    SSL_get_cipher_list
-    SSL_get_ciphers
-    ssl_get_ciphers_by_id
-    SSL_get_client_CA_list
-    SSL_get_current_cipher
-    SSL_get_current_compression
-    SSL_get_current_expansion
-    SSL_get_default_timeout
-    SSL_get_error
-    SSL_get_ex_data
-    SSL_get_ex_data_X509_STORE_CTX_idx
-    SSL_get_ex_new_index
-    SSL_get_fd
-    SSL_get_finished
-    ssl_get_handshake_digest
-    SSL_get_info_callback
-    ssl_get_new_session
-    SSL_get_peer_cert_chain
-    SSL_get_peer_certificate
-    SSL_get_peer_finished
-    ssl_get_prev_session
-    SSL_get_privatekey
-    SSL_get_psk_identity
-    SSL_get_psk_identity_hint
-    SSL_get_quiet_shutdown
-    SSL_get_rbio
-    SSL_get_read_ahead
-    SSL_get_rfd
-    SSL_get_selected_srtp_profile
-    ssl_get_server_send_cert
-    ssl_get_server_send_pkey
-    SSL_get_servername
-    SSL_get_servername_type
-    SSL_get_session
-    SSL_get_shared_ciphers
-    SSL_get_shutdown
-    ssl_get_sign_pkey
-    SSL_get_srp_g
-    SSL_get_srp_N
-    SSL_get_srp_userinfo
-    SSL_get_srp_username
-    SSL_get_srtp_profiles
-    SSL_get_SSL_CTX
-    SSL_get_ssl_method
-    SSL_get_verify_callback
-    SSL_get_verify_depth
-    SSL_get_verify_mode
-    SSL_get_verify_result
-    SSL_get_version
-    SSL_get_wbio
-    SSL_get_wfd
-    SSL_get0_next_proto_negotiated
-    SSL_get1_session
-    SSL_has_matching_session_id
-    ssl_init_wbio_buffer
-    SSL_library_init
-    ssl_load_ciphers
-    SSL_load_client_CA_file
-    SSL_load_error_strings
-    SSL_new
-    ssl_ok
-    ssl_parse_clienthello_renegotiate_ext
-    ssl_parse_clienthello_tlsext
-    ssl_parse_clienthello_use_srtp_ext
-    ssl_parse_serverhello_renegotiate_ext
-    ssl_parse_serverhello_tlsext
-    ssl_parse_serverhello_use_srtp_ext
-    SSL_peek
-    SSL_pending
-    ssl_prepare_clienthello_tlsext
-    ssl_prepare_serverhello_tlsext
-    SSL_read
-    SSL_renegotiate
-    SSL_renegotiate_abbreviated
-    SSL_renegotiate_pending
-    ssl_replace_hash
-    SSL_rstate_string
-    SSL_rstate_string_long
-    SSL_select_next_proto
-    ssl_sess_cert_free
-    ssl_sess_cert_new
-    SSL_SESSION_free
-    SSL_SESSION_get_compress_id
-    SSL_SESSION_get_ex_data
-    SSL_SESSION_get_ex_new_index
-    SSL_SESSION_get_id
-    SSL_SESSION_get_time
-    SSL_SESSION_get_timeout
-    SSL_SESSION_get0_peer
-    SSL_SESSION_new
-    SSL_SESSION_print
-    SSL_SESSION_print_fp
-    SSL_SESSION_set_ex_data
-    SSL_SESSION_set_time
-    SSL_SESSION_set_timeout
-    SSL_SESSION_set1_id_context
-    SSL_set_accept_state
-    SSL_set_bio
-    ssl_set_cert_masks
-    SSL_set_cipher_list
-    SSL_set_client_CA_list
-    SSL_set_connect_state
-    SSL_set_debug
-    SSL_set_ex_data
-    SSL_set_fd
-    SSL_set_generate_session_id
-    SSL_set_info_callback
-    SSL_set_msg_callback
-    ssl_set_peer_cert_type
-    SSL_set_psk_client_callback
-    SSL_set_psk_server_callback
-    SSL_set_purpose
-    SSL_set_quiet_shutdown
-    SSL_set_read_ahead
-    SSL_set_rfd
-    SSL_set_session
-    SSL_set_session_id_context
-    SSL_set_session_secret_cb
-    SSL_set_session_ticket_ext
-    SSL_set_session_ticket_ext_cb
-    SSL_set_shutdown
-    SSL_set_srp_server_param
-    SSL_set_srp_server_param_pw
-    SSL_set_SSL_CTX
-    SSL_set_ssl_method
-    SSL_set_state
-    SSL_set_tlsext_use_srtp
-    SSL_set_tmp_dh_callback
-    SSL_set_tmp_rsa_callback
-    SSL_set_trust
-    SSL_set_verify
-    SSL_set_verify_depth
-    SSL_set_verify_result
-    SSL_set_wfd
-    SSL_set1_param
-    SSL_shutdown
-    SSL_SRP_CTX_free
-    SSL_SRP_CTX_init
-    SSL_srp_server_param_with_username
-    SSL_state
-    SSL_state_string
-    SSL_state_string_long
-    ssl_undefined_const_function
-    ssl_undefined_function
-    ssl_undefined_void_function
-    ssl_update_cache
-    SSL_use_certificate
-    SSL_use_certificate_ASN1
-    SSL_use_certificate_file
-    SSL_use_PrivateKey
-    SSL_use_PrivateKey_ASN1
-    SSL_use_PrivateKey_file
-    SSL_use_psk_identity_hint
-    SSL_use_RSAPrivateKey
-    SSL_use_RSAPrivateKey_ASN1
-    SSL_use_RSAPrivateKey_file
-    ssl_verify_alarm_type
-    ssl_verify_cert_chain
-    SSL_version
-    SSL_want
-    SSL_write
-    ssl23_accept
-    ssl23_connect
-    ssl23_default_timeout
-    ssl23_get_cipher
-    ssl23_get_cipher_by_char
-    ssl23_get_client_hello
-    ssl23_num_ciphers
-    ssl23_peek
-    ssl23_put_cipher_by_char
-    ssl23_read
-    ssl23_read_bytes
-    ssl23_write
-    ssl23_write_bytes
-    ssl3_accept
-    ssl3_alert_code
-    ssl3_callback_ctrl
-    ssl3_cbc_copy_mac
-    ssl3_cbc_digest_record
-    ssl3_cbc_record_digest_supported
-    ssl3_cbc_remove_padding
-    ssl3_cert_verify_mac
-    ssl3_change_cipher_state
-    ssl3_check_cert_and_algorithm
-    ssl3_check_client_hello
-    ssl3_choose_cipher
-    ssl3_cleanup_key_block
-    ssl3_clear
-    ssl3_client_hello
-    ssl3_comp_find
-    ssl3_connect
-    ssl3_ctrl
-    ssl3_ctx_callback_ctrl
-    ssl3_ctx_ctrl
-    ssl3_default_timeout
-    ssl3_digest_cached_records
-    ssl3_dispatch_alert
-    ssl3_do_change_cipher_spec
-    ssl3_do_compress
-    ssl3_do_uncompress
-    ssl3_do_write
-    ssl3_enc
-    ssl3_final_finish_mac
-    ssl3_finish_mac
-    ssl3_free
-    ssl3_free_digest_list
-    ssl3_generate_master_secret
-    ssl3_get_cert_status
-    ssl3_get_cert_verify
-    ssl3_get_certificate_request
-    ssl3_get_cipher
-    ssl3_get_cipher_by_char
-    ssl3_get_client_certificate
-    ssl3_get_client_hello
-    ssl3_get_client_key_exchange
-    ssl3_get_finished
-    ssl3_get_key_exchange
-    ssl3_get_message
-    ssl3_get_new_session_ticket
-    ssl3_get_next_proto
-    ssl3_get_req_cert_type
-    ssl3_get_server_certificate
-    ssl3_get_server_done
-    ssl3_get_server_hello
-    ssl3_init_finished_mac
-    ssl3_new
-    ssl3_num_ciphers
-    ssl3_output_cert_chain
-    ssl3_peek
-    ssl3_pending
-    ssl3_put_cipher_by_char
-    ssl3_read
-    ssl3_read_bytes
-    ssl3_read_n
-    ssl3_record_sequence_update
-    ssl3_release_read_buffer
-    ssl3_release_write_buffer
-    ssl3_renegotiate
-    ssl3_renegotiate_check
-    ssl3_send_alert
-    ssl3_send_cert_status
-    ssl3_send_certificate_request
-    ssl3_send_change_cipher_spec
-    ssl3_send_client_certificate
-    ssl3_send_client_key_exchange
-    ssl3_send_client_verify
-    ssl3_send_finished
-    ssl3_send_hello_request
-    ssl3_send_newsession_ticket
-    ssl3_send_next_proto
-    ssl3_send_server_certificate
-    ssl3_send_server_done
-    ssl3_send_server_hello
-    ssl3_send_server_key_exchange
-    ssl3_setup_buffers
-    ssl3_setup_key_block
-    ssl3_setup_read_buffer
-    ssl3_setup_write_buffer
-    ssl3_shutdown
-    ssl3_write
-    ssl3_write_bytes
-    ssl3_write_pending
-    SSLv23_client_method
-    SSLv23_method
-    SSLv23_server_method
-    SSLv3_client_method
-    SSLv3_method
-    SSLv3_server_method
-    tls1_alert_code
-    tls1_cbc_remove_padding
-    tls1_cert_verify_mac
-    tls1_change_cipher_state
-    tls1_clear
-    tls1_default_timeout
-    tls1_enc
-    tls1_export_keying_material
-    tls1_final_finish_mac
-    tls1_free
-    tls1_generate_master_secret
-    tls1_heartbeat
-    tls1_mac
-    tls1_new
-    tls1_process_heartbeat
-    tls1_process_sigalgs
-    tls1_process_ticket
-    tls1_setup_key_block
-    tls12_get_hash
-    tls12_get_req_sig_algs
-    tls12_get_sigandhash
-    tls12_get_sigid
-    TLSv1_1_client_method
-    TLSv1_1_method
-    TLSv1_1_server_method
-    TLSv1_2_client_method
-    TLSv1_2_method
-    TLSv1_2_server_method
-    TLSv1_client_method
-    TLSv1_method
-    TLSv1_server_method
diff --git a/src/VBox/Runtime/r3/win/mp-win.cpp b/src/VBox/Runtime/r3/win/mp-win.cpp
index e723e5d..94cf53d 100644
--- a/src/VBox/Runtime/r3/win/mp-win.cpp
+++ b/src/VBox/Runtime/r3/win/mp-win.cpp
@@ -38,141 +38,765 @@
 #include <iprt/cpuset.h>
 #include <iprt/ldr.h>
 #include <iprt/mem.h>
+#include <iprt/once.h>
+#include <iprt/param.h>
+#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
+# include <iprt/asm-amd64-x86.h>
+#endif
+#if defined(VBOX) && !defined(IN_GUEST) && !defined(IN_RT_STATIC)
+# include <VBox/sup.h>
+# define IPRT_WITH_GIP_MP_INFO
+#else
+# undef  IPRT_WITH_GIP_MP_INFO
+#endif
 
+#include "internal-r3-win.h"
 
-AssertCompile(MAXIMUM_PROCESSORS <= RTCPUSET_MAX_CPUS);
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+/** @def RTMPWIN_UPDATE_GIP_GLOBALS
+ * Does lazy (re-)initialization using information provieded by GIP. */
+#ifdef IPRT_WITH_GIP_MP_INFO
+# define RTMPWIN_UPDATE_GIP_GLOBALS() \
+    do { RTMPWIN_UPDATE_GIP_GLOBALS_AND_GET_PGIP(); } while (0)
+#else
+# define RTMPWIN_UPDATE_GIP_GLOBALS() do { } while (0)
+#endif
+
+/** @def RTMPWIN_UPDATE_GIP_GLOBALS_AND_GET_PGIP
+ * Does lazy (re-)initialization using information provieded by GIP and
+ * declare and initalize a pGip local variable. */
+#ifdef IPRT_WITH_GIP_MP_INFO
+#define RTMPWIN_UPDATE_GIP_GLOBALS_AND_GET_PGIP() \
+    PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage; \
+    if (pGip) \
+    { \
+        if (   pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC \
+            && RTOnce(&g_MpInitOnceGip, rtMpWinInitOnceGip, NULL) == VINF_SUCCESS) \
+        { \
+            if (g_cRtMpWinActiveCpus >= pGip->cOnlineCpus) \
+            { /* likely */ } \
+            else \
+                rtMpWinRefreshGip(); \
+        } \
+        else \
+            pGip = NULL; \
+    } else do { } while (0)
+#else
+# define RTMPWIN_UPDATE_GIP_GLOBALS_AND_GET_PGIP() do { } while (0)
+#endif
+
+
+/*********************************************************************************************************************************
+*   Global Variables                                                                                                             *
+*********************************************************************************************************************************/
+/** Initialize once. */
+static RTONCE                                       g_MpInitOnce = RTONCE_INITIALIZER;
+#ifdef IPRT_WITH_GIP_MP_INFO
+/** Initialize once using GIP. */
+static RTONCE                                       g_MpInitOnceGip = RTONCE_INITIALIZER;
+#endif
+
+static decltype(GetMaximumProcessorCount)          *g_pfnGetMaximumProcessorCount;
+//static decltype(GetActiveProcessorCount)           *g_pfnGetActiveProcessorCount;
+static decltype(GetCurrentProcessorNumber)         *g_pfnGetCurrentProcessorNumber;
+static decltype(GetCurrentProcessorNumberEx)       *g_pfnGetCurrentProcessorNumberEx;
+static decltype(GetLogicalProcessorInformation)    *g_pfnGetLogicalProcessorInformation;
+static decltype(GetLogicalProcessorInformationEx)  *g_pfnGetLogicalProcessorInformationEx;
+
+
+/** The required buffer size for getting group relations. */
+static uint32_t     g_cbRtMpWinGrpRelBuf;
+/** The max number of CPUs (RTMpGetCount). */
+static uint32_t     g_cRtMpWinMaxCpus;
+/** The max number of CPU cores (RTMpGetCoreCount). */
+static uint32_t     g_cRtMpWinMaxCpuCores;
+/** The max number of groups. */
+static uint32_t     g_cRtMpWinMaxCpuGroups;
+/** The number of active CPUs the last time we checked. */
+static uint32_t volatile g_cRtMpWinActiveCpus;
+/** Static per group info.
+ * @remarks  With RTCPUSET_MAX_CPUS as 256, this takes up 33KB.
+ * @sa g_aRtMpNtCpuGroups */
+static struct
+{
+    /** The max CPUs in the group. */
+    uint16_t    cMaxCpus;
+    /** The number of active CPUs at the time of initialization. */
+    uint16_t    cActiveCpus;
+    /** CPU set indexes for each CPU in the group. */
+    int16_t     aidxCpuSetMembers[64];
+}                   g_aRtMpWinCpuGroups[RTCPUSET_MAX_CPUS];
+/** Maps CPU set indexes to RTCPUID.
+ * @sa g_aidRtMpNtByCpuSetIdx  */
+RTCPUID             g_aidRtMpWinByCpuSetIdx[RTCPUSET_MAX_CPUS];
+
+
+/**
+ * @callback_method_impl{FNRTONCE,
+ *      Resolves dynamic imports and initializes globals.}
+ */
+static DECLCALLBACK(int32_t) rtMpWinInitOnce(void *pvUser)
+{
+    RT_NOREF(pvUser);
+
+    Assert(g_WinOsInfoEx.dwOSVersionInfoSize != 0);
+    Assert(g_hModKernel32 != NULL);
+
+    /*
+     * Resolve dynamic APIs.
+     */
+#define RESOLVE_API(a_szMod, a_FnName) \
+        do { \
+            RT_CONCAT(g_pfn,a_FnName) = (decltype(a_FnName) *)GetProcAddress(g_hModKernel32, #a_FnName); \
+        } while (0)
+    RESOLVE_API("kernel32.dll", GetMaximumProcessorCount);
+    //RESOLVE_API("kernel32.dll", GetActiveProcessorCount); - slow :/
+    RESOLVE_API("kernel32.dll", GetCurrentProcessorNumber);
+    RESOLVE_API("kernel32.dll", GetCurrentProcessorNumberEx);
+    RESOLVE_API("kernel32.dll", GetLogicalProcessorInformation);
+    RESOLVE_API("kernel32.dll", GetLogicalProcessorInformationEx);
+
+    /*
+     * Reset globals.
+     */
+    for (unsigned i = 0; i < RT_ELEMENTS(g_aidRtMpWinByCpuSetIdx); i++)
+        g_aidRtMpWinByCpuSetIdx[i] = NIL_RTCPUID;
+    for (unsigned idxGroup = 0; idxGroup < RT_ELEMENTS(g_aRtMpWinCpuGroups); idxGroup++)
+    {
+        g_aRtMpWinCpuGroups[idxGroup].cMaxCpus    = 0;
+        g_aRtMpWinCpuGroups[idxGroup].cActiveCpus = 0;
+        for (unsigned idxMember = 0; idxMember < RT_ELEMENTS(g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers); idxMember++)
+            g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = -1;
+    }
+
+    /*
+     * Query group information, partitioning CPU IDs and CPU set indexes.
+     *
+     * We ASSUME the the GroupInfo index is the same as the group number.
+     *
+     * We CANNOT ASSUME that the kernel CPU indexes are assigned in any given
+     * way, though they usually are in group order by active processor.  So,
+     * we do that to avoid trouble.  We must use information provided thru GIP
+     * if we want the kernel CPU set indexes.  Even there, the inactive CPUs
+     * wont have sensible indexes.  Sigh.
+     *
+     * We try to assign IDs to inactive CPUs in the same manner as mp-r0drv-nt.cpp
+     *
+     * Note! We will die (AssertFatal) if there are too many processors!
+     */
+    union
+    {
+        SYSTEM_INFO                                 SysInfo;
+        SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX     Info;
+        uint8_t                                     abPaddingG[  sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)
+                                                               + sizeof(PROCESSOR_GROUP_INFO) * RTCPUSET_MAX_CPUS];
+        uint8_t                                     abPaddingC[  sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)
+                                                               +   (sizeof(PROCESSOR_RELATIONSHIP) + sizeof(GROUP_AFFINITY))
+                                                                 * RTCPUSET_MAX_CPUS];
+    } uBuf;
+    if (g_pfnGetLogicalProcessorInformationEx)
+    {
+        /* Query the information. */
+        DWORD cbData = sizeof(uBuf);
+        AssertFatalMsg(g_pfnGetLogicalProcessorInformationEx(RelationGroup, &uBuf.Info, &cbData) != FALSE,
+                       ("last error = %u, cbData = %u (in %u)\n", GetLastError(), cbData, sizeof(uBuf)));
+        AssertFatalMsg(uBuf.Info.Relationship == RelationGroup,
+                       ("Relationship = %u, expected %u!\n", uBuf.Info.Relationship, RelationGroup));
+        AssertFatalMsg(uBuf.Info.Group.MaximumGroupCount <= RT_ELEMENTS(g_aRtMpWinCpuGroups),
+                       ("MaximumGroupCount is %u, we only support up to %u!\n",
+                        uBuf.Info.Group.MaximumGroupCount, RT_ELEMENTS(g_aRtMpWinCpuGroups)));
+
+        AssertMsg(uBuf.Info.Group.MaximumGroupCount == uBuf.Info.Group.ActiveGroupCount, /* 2nd assumption mentioned above. */
+                  ("%u vs %u\n", uBuf.Info.Group.MaximumGroupCount, uBuf.Info.Group.ActiveGroupCount));
+        AssertFatal(uBuf.Info.Group.MaximumGroupCount >= uBuf.Info.Group.ActiveGroupCount);
+
+        g_cRtMpWinMaxCpuGroups = uBuf.Info.Group.MaximumGroupCount;
+
+        /* Count max cpus (see mp-r0drv0-nt.cpp) why we don't use GetMaximumProcessorCount(ALL). */
+        uint32_t idxGroup;
+        g_cRtMpWinMaxCpus = 0;
+        for (idxGroup = 0; idxGroup < uBuf.Info.Group.ActiveGroupCount; idxGroup++)
+            g_cRtMpWinMaxCpus += uBuf.Info.Group.GroupInfo[idxGroup].MaximumProcessorCount;
+
+        /* Process the active groups. */
+        uint32_t cActive   = 0;
+        uint32_t cInactive = 0;
+        uint32_t idxCpu    = 0;
+        uint32_t idxCpuSetNextInactive = g_cRtMpWinMaxCpus - 1;
+        for (idxGroup = 0; idxGroup < uBuf.Info.Group.ActiveGroupCount; idxGroup++)
+        {
+            PROCESSOR_GROUP_INFO const *pGroupInfo = &uBuf.Info.Group.GroupInfo[idxGroup];
+            g_aRtMpWinCpuGroups[idxGroup].cMaxCpus    = pGroupInfo->MaximumProcessorCount;
+            g_aRtMpWinCpuGroups[idxGroup].cActiveCpus = pGroupInfo->ActiveProcessorCount;
+            for (uint32_t idxMember = 0; idxMember < pGroupInfo->MaximumProcessorCount; idxMember++)
+            {
+                if (pGroupInfo->ActiveProcessorMask & RT_BIT_64(idxMember))
+                {
+                    g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxCpu;
+                    g_aidRtMpWinByCpuSetIdx[idxCpu] = idxCpu;
+                    idxCpu++;
+                    cActive++;
+                }
+                else
+                {
+                    if (idxCpuSetNextInactive >= idxCpu)
+                    {
+                        g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxCpuSetNextInactive;
+                        g_aidRtMpWinByCpuSetIdx[idxCpuSetNextInactive] = idxCpuSetNextInactive;
+                        idxCpuSetNextInactive--;
+                    }
+                    cInactive++;
+                }
+            }
+        }
+        g_cRtMpWinActiveCpus = cActive;
+        Assert(cActive + cInactive <= g_cRtMpWinMaxCpus);
+        Assert(idxCpu <= idxCpuSetNextInactive + 1);
+        Assert(idxCpu <= g_cRtMpWinMaxCpus);
+
+        /* Just in case the 2nd assumption doesn't hold true and there are inactive groups. */
+        for (; idxGroup < uBuf.Info.Group.MaximumGroupCount; idxGroup++)
+        {
+            DWORD cMaxMembers = g_pfnGetMaximumProcessorCount(idxGroup);
+            g_aRtMpWinCpuGroups[idxGroup].cMaxCpus    = cMaxMembers;
+            g_aRtMpWinCpuGroups[idxGroup].cActiveCpus = 0;
+            for (uint32_t idxMember = 0; idxMember < cMaxMembers; idxMember++)
+            {
+                if (idxCpuSetNextInactive >= idxCpu)
+                {
+                    g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxCpuSetNextInactive;
+                    g_aidRtMpWinByCpuSetIdx[idxCpuSetNextInactive] = idxCpuSetNextInactive;
+                    idxCpuSetNextInactive--;
+                }
+                cInactive++;
+            }
+        }
+        Assert(cActive + cInactive <= g_cRtMpWinMaxCpus);
+        Assert(idxCpu <= idxCpuSetNextInactive + 1);
+    }
+    else
+    {
+        /* Legacy: */
+        GetSystemInfo(&uBuf.SysInfo);
+        g_cRtMpWinMaxCpuGroups              = 1;
+        g_cRtMpWinMaxCpus                   = uBuf.SysInfo.dwNumberOfProcessors;
+        g_aRtMpWinCpuGroups[0].cMaxCpus     = uBuf.SysInfo.dwNumberOfProcessors;
+        g_aRtMpWinCpuGroups[0].cActiveCpus  = uBuf.SysInfo.dwNumberOfProcessors;
+
+        for (uint32_t idxMember = 0; idxMember < uBuf.SysInfo.dwNumberOfProcessors; idxMember++)
+        {
+            g_aRtMpWinCpuGroups[0].aidxCpuSetMembers[idxMember] = idxMember;
+            g_aidRtMpWinByCpuSetIdx[idxMember] = idxMember;
+        }
+    }
+
+    AssertFatalMsg(g_cRtMpWinMaxCpus <= RTCPUSET_MAX_CPUS,
+                   ("g_cRtMpWinMaxCpus=%u (%#x); RTCPUSET_MAX_CPUS=%u\n", g_cRtMpWinMaxCpus, g_cRtMpWinMaxCpus, RTCPUSET_MAX_CPUS));
+
+    g_cbRtMpWinGrpRelBuf = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)
+                         + (g_cRtMpWinMaxCpuGroups + 2) * sizeof(PROCESSOR_GROUP_INFO);
+
+    /*
+     * Get information about cores.
+     *
+     * Note! This will only give us info about active processors according to
+     *       MSDN, we'll just have to hope that CPUs aren't hotplugged after we
+     *       initialize here (or that the API consumers doesn't care too much).
+     */
+    /** @todo A hot CPU plug event would be nice. */
+    g_cRtMpWinMaxCpuCores = g_cRtMpWinMaxCpus;
+    if (g_pfnGetLogicalProcessorInformationEx)
+    {
+        /* Query the information. */
+        DWORD cbData = sizeof(uBuf);
+        AssertFatalMsg(g_pfnGetLogicalProcessorInformationEx(RelationProcessorCore, &uBuf.Info, &cbData) != FALSE,
+                       ("last error = %u, cbData = %u (in %u)\n", GetLastError(), cbData, sizeof(uBuf)));
+        g_cRtMpWinMaxCpuCores = 0;
+        for (uint32_t off = 0; off < cbData; )
+        {
+            SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pCur = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)&uBuf.abPaddingG[off];
+            AssertFatalMsg(pCur->Relationship == RelationProcessorCore,
+                           ("off = %#x, Relationship = %u, expected %u!\n", off, pCur->Relationship, RelationProcessorCore));
+            g_cRtMpWinMaxCpuCores++;
+            off += pCur->Size;
+        }
+
+#if ARCH_BITS == 32
+        if (g_cRtMpWinMaxCpuCores > g_cRtMpWinMaxCpus)
+        {
+            /** @todo WOW64 trouble where the emulation environment has folded the high
+             *        processor masks (63..32) into the low (31..0), hiding some
+             *        processors from us.  Currently we don't deal with that. */
+            g_cRtMpWinMaxCpuCores = g_cRtMpWinMaxCpus;
+        }
+        else
+            AssertStmt(g_cRtMpWinMaxCpuCores > 0, g_cRtMpWinMaxCpuCores = g_cRtMpWinMaxCpus);
+#else
+        AssertStmt(g_cRtMpWinMaxCpuCores > 0 && g_cRtMpWinMaxCpuCores <= g_cRtMpWinMaxCpus,
+                   g_cRtMpWinMaxCpuCores = g_cRtMpWinMaxCpus);
+#endif
+    }
+    else
+    {
+        /*
+         * Sadly, on XP and Server 2003, even if the API is present, it does not tell us
+         * how many physical cores there are (any package will look like a single core).
+         * That is worse than not using the API at all, so just skip it unless it's Vista+.
+         */
+        if (   g_pfnGetLogicalProcessorInformation
+            && g_WinOsInfoEx.dwPlatformId == VER_PLATFORM_WIN32_NT
+            && g_WinOsInfoEx.dwMajorVersion >= 6)
+        {
+            /* Query the info. */
+            DWORD                                   cbSysProcInfo = _4K;
+            PSYSTEM_LOGICAL_PROCESSOR_INFORMATION   paSysInfo = NULL;
+            BOOL                                    fRc = FALSE;
+            do
+            {
+                cbSysProcInfo = RT_ALIGN_32(cbSysProcInfo, 256);
+                void *pv = RTMemRealloc(paSysInfo, cbSysProcInfo);
+                if (!pv)
+                    break;
+                paSysInfo = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)pv;
+                fRc = g_pfnGetLogicalProcessorInformation(paSysInfo, &cbSysProcInfo);
+            } while (!fRc && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
+            if (fRc)
+            {
+                /* Count the cores in the result. */
+                g_cRtMpWinMaxCpuCores = 0;
+                uint32_t i = cbSysProcInfo / sizeof(paSysInfo[0]);
+                while (i-- > 0)
+                    if (paSysInfo[i].Relationship == RelationProcessorCore)
+                        g_cRtMpWinMaxCpuCores++;
+
+                AssertStmt(g_cRtMpWinMaxCpuCores > 0 && g_cRtMpWinMaxCpuCores <= g_cRtMpWinMaxCpus,
+                           g_cRtMpWinMaxCpuCores = g_cRtMpWinMaxCpus);
+            }
+            RTMemFree(paSysInfo);
+        }
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+#ifdef IPRT_WITH_GIP_MP_INFO
+/**
+ * @callback_method_impl{FNRTONCE, Updates globals with information from GIP.}
+ */
+static DECLCALLBACK(int32_t) rtMpWinInitOnceGip(void *pvUser)
+{
+    RT_NOREF(pvUser);
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+
+    PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
+    if (   pGip
+        && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC)
+    {
+        /*
+         * Update globals.
+         */
+        if (g_cRtMpWinMaxCpus != pGip->cPossibleCpus)
+            g_cRtMpWinMaxCpus = pGip->cPossibleCpus;
+        if (g_cRtMpWinActiveCpus != pGip->cOnlineCpus)
+            g_cRtMpWinActiveCpus = pGip->cOnlineCpus;
+        Assert(g_cRtMpWinMaxCpuGroups == pGip->cPossibleCpuGroups);
+        if (g_cRtMpWinMaxCpuGroups != pGip->cPossibleCpuGroups)
+        {
+            g_cRtMpWinMaxCpuGroups = pGip->cPossibleCpuGroups;
+            g_cbRtMpWinGrpRelBuf   = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)
+                                   + (g_cRtMpWinMaxCpuGroups + 2) * sizeof(PROCESSOR_GROUP_INFO);
+        }
+
+        /*
+         * Update CPU set IDs.
+         */
+        for (unsigned i = g_cRtMpWinMaxCpus; i < RT_ELEMENTS(g_aidRtMpWinByCpuSetIdx); i++)
+            g_aidRtMpWinByCpuSetIdx[i] = NIL_RTCPUID;
+
+        unsigned const cbGip = pGip->cPages * PAGE_SIZE;
+        for (uint32_t idxGroup = 0; idxGroup < g_cRtMpWinMaxCpus; idxGroup++)
+        {
+            uint32_t idxMember;
+            unsigned offCpuGroup = pGip->aoffCpuGroup[idxGroup];
+            if (offCpuGroup < cbGip)
+            {
+                PSUPGIPCPUGROUP pGipCpuGrp  = (PSUPGIPCPUGROUP)((uintptr_t)pGip + offCpuGroup);
+                uint32_t        cMaxMembers = pGipCpuGrp->cMaxMembers;
+                AssertStmt(cMaxMembers < RT_ELEMENTS(g_aRtMpWinCpuGroups[0].aidxCpuSetMembers),
+                           cMaxMembers = RT_ELEMENTS(g_aRtMpWinCpuGroups[0].aidxCpuSetMembers));
+                g_aRtMpWinCpuGroups[idxGroup].cMaxCpus     = cMaxMembers;
+                g_aRtMpWinCpuGroups[idxGroup].cActiveCpus  = RT_MIN(pGipCpuGrp->cMembers, cMaxMembers);
+
+                for (idxMember = 0; idxMember < cMaxMembers; idxMember++)
+                {
+                    int16_t idxSet = pGipCpuGrp->aiCpuSetIdxs[idxMember];
+                    g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxSet;
+                    if ((unsigned)idxSet < RT_ELEMENTS(g_aidRtMpWinByCpuSetIdx))
+# ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                        g_aidRtMpWinByCpuSetIdx[idxSet] = RTMPCPUID_FROM_GROUP_AND_NUMBER(idxGroup, idxMember);
+# else
+                        g_aidRtMpWinByCpuSetIdx[idxSet] = idxSet;
+# endif
+                }
+            }
+            else
+                idxMember = 0;
+            for (; idxMember < RT_ELEMENTS(g_aRtMpWinCpuGroups[0].aidxCpuSetMembers); idxMember++)
+                g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = -1;
+        }
+    }
+
+    return VINF_SUCCESS;
+}
 
 
-/** @todo RTmpCpuId(). */
+/**
+ * Refreshes globals from GIP after one or more CPUs were added.
+ *
+ * There are potential races here.  We might race other threads and we may race
+ * more CPUs being added.
+ */
+static void rtMpWinRefreshGip(void)
+{
+    PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
+    if (   pGip
+        && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC)
+    {
+        /*
+         * Since CPUs cannot be removed, we only have to update the IDs and
+         * indexes of CPUs that we think are inactive and the group member counts.
+         */
+        for (;;)
+        {
+            unsigned const cbGip          = pGip->cPages * PAGE_SIZE;
+            uint32_t const cGipActiveCpus = pGip->cOnlineCpus;
+            uint32_t const cMyActiveCpus  = ASMAtomicReadU32(&g_cRtMpWinActiveCpus);
+            ASMCompilerBarrier();
+
+            for (uint32_t idxGroup = 0; idxGroup < g_cRtMpWinMaxCpus; idxGroup++)
+            {
+                unsigned offCpuGroup = pGip->aoffCpuGroup[idxGroup];
+                if (offCpuGroup < cbGip)
+                {
+                    PSUPGIPCPUGROUP pGipCpuGrp  = (PSUPGIPCPUGROUP)((uintptr_t)pGip + offCpuGroup);
+                    uint32_t        cMaxMembers = pGipCpuGrp->cMaxMembers;
+                    AssertStmt(cMaxMembers < RT_ELEMENTS(g_aRtMpWinCpuGroups[0].aidxCpuSetMembers),
+                               cMaxMembers = RT_ELEMENTS(g_aRtMpWinCpuGroups[0].aidxCpuSetMembers));
+                    for (uint32_t idxMember = g_aRtMpWinCpuGroups[idxGroup].cActiveCpus; idxMember < cMaxMembers; idxMember++)
+                    {
+                        int16_t idxSet = pGipCpuGrp->aiCpuSetIdxs[idxMember];
+                        g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember] = idxSet;
+                        if ((unsigned)idxSet < RT_ELEMENTS(g_aidRtMpWinByCpuSetIdx))
+# ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+                            g_aidRtMpWinByCpuSetIdx[idxSet] = RTMPCPUID_FROM_GROUP_AND_NUMBER(idxGroup, idxMember);
+# else
+                            g_aidRtMpWinByCpuSetIdx[idxSet] = idxSet;
+# endif
+                    }
+                    g_aRtMpWinCpuGroups[idxGroup].cMaxCpus    = RT_MIN(pGipCpuGrp->cMembers, cMaxMembers);
+                    g_aRtMpWinCpuGroups[idxGroup].cActiveCpus = RT_MIN(pGipCpuGrp->cMembers, cMaxMembers);
+                }
+                else
+                    Assert(g_aRtMpWinCpuGroups[idxGroup].cActiveCpus == 0);
+            }
+
+            ASMCompilerBarrier();
+            if (cGipActiveCpus == pGip->cOnlineCpus)
+                if (ASMAtomicCmpXchgU32(&g_cRtMpWinActiveCpus, cGipActiveCpus, cMyActiveCpus))
+                    break;
+        }
+    }
+}
+
+#endif /* IPRT_WITH_GIP_MP_INFO */
+
+
+/*
+ * Conversion between CPU ID and set index.
+ */
 
 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
 {
-    return idCpu < MAXIMUM_PROCESSORS ? idCpu : -1;
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    if (idCpu != NIL_RTCPUID)
+        return RTMpSetIndexFromCpuGroupMember(rtMpCpuIdGetGroup(idCpu), rtMpCpuIdGetGroupMember(idCpu));
+    return -1;
+
+#else
+    /* 1:1 mapping, just do range checking. */
+    return idCpu < g_cRtMpWinMaxCpus ? idCpu : -1;
+#endif
 }
 
 
 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
 {
-    return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID;
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    if ((unsigned)iCpu < RT_ELEMENTS(g_aidRtMpWinByCpuSetIdx))
+    {
+        RTCPUID idCpu = g_aidRtMpWinByCpuSetIdx[iCpu];
+
+#if defined(IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER) && defined(RT_STRICT)
+        /* Check the correctness of the mapping table. */
+        RTCPUID idCpuGip = NIL_RTCPUID;
+        if (   pGip
+            && (unsigned)iCpu < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx))
+        {
+            unsigned idxSupCpu = pGip->aiCpuFromCpuSetIdx[idxGuess];
+            if (idxSupCpu < pGip->cCpus)
+                if (pGip->aCPUs[idxSupCpu].enmState != SUPGIPCPUSTATE_INVALID)
+                    idCpuGip = pGip->aCPUs[idxSupCpu].idCpu;
+        }
+        AssertMsg(idCpu == idCpuGip, ("table:%#x  gip:%#x\n", idCpu, idCpuGip));
+#endif
+
+        return idCpu;
+    }
+    return NIL_RTCPUID;
 }
 
 
-RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
+RTDECL(int) RTMpSetIndexFromCpuGroupMember(uint32_t idxGroup, uint32_t idxMember)
 {
-    return MAXIMUM_PROCESSORS - 1;
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    if (idxGroup < g_cRtMpWinMaxCpuGroups)
+        if (idxMember < g_aRtMpWinCpuGroups[idxGroup].cMaxCpus)
+            return g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember];
+    return -1;
 }
 
 
-RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
+RTDECL(uint32_t) RTMpGetCpuGroupCounts(uint32_t idxGroup, uint32_t *pcActive)
 {
-    RTCPUSET Set;
-    return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    if (idxGroup < g_cRtMpWinMaxCpuGroups)
+    {
+        if (pcActive)
+            *pcActive = g_aRtMpWinCpuGroups[idxGroup].cActiveCpus;
+        return g_aRtMpWinCpuGroups[idxGroup].cMaxCpus;
+    }
+    if (pcActive)
+        *pcActive = 0;
+    return 0;
+}
+
+
+RTDECL(uint32_t) RTMpGetMaxCpuGroupCount(void)
+{
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    return g_cRtMpWinMaxCpuGroups;
+}
+
+
+
+/*
+ * Get current CPU.
+ */
+
+RTDECL(RTCPUID) RTMpCpuId(void)
+{
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    PROCESSOR_NUMBER ProcNum;
+    ProcNum.Group = 0;
+    ProcNum.Number = 0xff;
+    if (g_pfnGetCurrentProcessorNumberEx)
+        g_pfnGetCurrentProcessorNumberEx(&ProcNum);
+    else if (g_pfnGetCurrentProcessorNumber)
+    {
+        DWORD iCpu = g_pfnGetCurrentProcessorNumber();
+        Assert(iCpu < g_cRtMpWinMaxCpus);
+        ProcNum.Number = iCpu;
+    }
+    else
+    {
+#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
+        ProcNum.Number = ASMGetApicId();
+#else
+# error "Not ported to this architecture."
+        return NIL_RTCPUID;
+#endif
+    }
+
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    return RTMPCPUID_FROM_GROUP_AND_NUMBER(ProcNum.Group, ProcNum.Number);
+#else
+    return RTMpSetIndexFromCpuGroupMember(ProcNum.Group, ProcNum.Number);
+#endif
+}
+
+
+/*
+ * Possible CPUs and cores.
+ */
+
+RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
+{
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+#ifdef IPRT_WITH_RTCPUID_AS_GROUP_AND_NUMBER
+    return RTMPCPUID_FROM_GROUP_AND_NUMBER(g_cRtMpWinMaxCpuGroups - 1,
+                                           g_aRtMpWinCpuGroups[g_cRtMpWinMaxCpuGroups - 1].cMaxCpus - 1);
+#else
+    return g_cRtMpWinMaxCpus - 1;
+#endif
 }
 
 
 RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
 {
-    RTCPUSET Set;
-    return RTCpuSetIsMember(RTMpGetSet(&Set), idCpu);
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    /* Any CPU between 0 and g_cRtMpWinMaxCpus are possible. */
+    return idCpu < g_cRtMpWinMaxCpus;
 }
 
 
 RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
 {
-    RTCPUID idCpu = RTMpGetCount();
+    RTCPUID iCpu = RTMpGetCount();
     RTCpuSetEmpty(pSet);
-    while (idCpu-- > 0)
-        RTCpuSetAdd(pSet, idCpu);
+    while (iCpu-- > 0)
+        RTCpuSetAddByIndex(pSet, iCpu);
     return pSet;
 }
 
 
 RTDECL(RTCPUID) RTMpGetCount(void)
 {
-    SYSTEM_INFO SysInfo;
-    GetSystemInfo(&SysInfo);
-    Assert((RTCPUID)SysInfo.dwNumberOfProcessors == SysInfo.dwNumberOfProcessors);
-    return SysInfo.dwNumberOfProcessors;
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
+
+    return g_cRtMpWinMaxCpus;
 }
 
 
 RTDECL(RTCPUID) RTMpGetCoreCount(void)
 {
-    /*
-     * Resolve the API dynamically (one try) as it requires XP w/ sp3 or later.
-     */
-    typedef BOOL (WINAPI *PFNGETLOGICALPROCINFO)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
-    static PFNGETLOGICALPROCINFO s_pfnGetLogicalProcInfo = (PFNGETLOGICALPROCINFO)~(uintptr_t)0;
-    if (s_pfnGetLogicalProcInfo == (PFNGETLOGICALPROCINFO)~(uintptr_t)0)
-        s_pfnGetLogicalProcInfo = (PFNGETLOGICALPROCINFO)RTLdrGetSystemSymbol("kernel32.dll", "GetLogicalProcessorInformation");
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+    RTMPWIN_UPDATE_GIP_GLOBALS();
 
-    /*
-     * Sadly, on XP and Server 2003, even if the API is present, it does not tell us
-     * how many physical cores there are (any package will look like a single core).
-     * That is worse than not using the API at all, so just skip it unless it's Vista+.
-     */
-    bool fIsVistaOrLater = false;
-    OSVERSIONINFOEX OSInfoEx = { 0 };
-    OSInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
-    if (   GetVersionEx((LPOSVERSIONINFO) &OSInfoEx)
-        && (OSInfoEx.dwPlatformId == VER_PLATFORM_WIN32_NT)
-        && (OSInfoEx.dwMajorVersion >= 6))
-        fIsVistaOrLater = true;
-
-    if (s_pfnGetLogicalProcInfo && fIsVistaOrLater)
+    return g_cRtMpWinMaxCpuCores;
+}
+
+
+/*
+ * Online CPUs and cores.
+ */
+
+RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
+{
+    RTOnce(&g_MpInitOnce, rtMpWinInitOnce, NULL);
+
+#ifdef IPRT_WITH_GIP_MP_INFO
+    RTMPWIN_UPDATE_GIP_GLOBALS_AND_GET_PGIP();
+    if (pGip)
+    {
+        *pSet = pGip->OnlineCpuSet;
+        return pSet;
+    }
+#endif
+
+    if (g_pfnGetLogicalProcessorInformationEx)
     {
         /*
-         * Query the information. This unfortunately requires a buffer, so we
-         * start with a guess and let windows advice us if it's too small.
+         * Get the group relation info.
+         *
+         * In addition to the ASSUMPTIONS that are documented in rtMpWinInitOnce,
+         * we ASSUME that PROCESSOR_GROUP_INFO::MaximumProcessorCount gives the
+         * active processor mask width.
          */
-        DWORD                                   cbSysProcInfo = _4K;
-        PSYSTEM_LOGICAL_PROCESSOR_INFORMATION   paSysInfo = NULL;
-        BOOL                                    fRc = FALSE;
-        do
-        {
-            cbSysProcInfo = RT_ALIGN_32(cbSysProcInfo, 256);
-            void *pv = RTMemRealloc(paSysInfo, cbSysProcInfo);
-            if (!pv)
-                break;
-            paSysInfo = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)pv;
-            fRc = s_pfnGetLogicalProcInfo(paSysInfo, &cbSysProcInfo);
-        } while (!fRc && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
-        if (fRc)
+        /** @todo this is not correct for WOW64   */
+        DWORD                                    cbInfo = g_cbRtMpWinGrpRelBuf;
+        SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)alloca(cbInfo);
+        AssertFatalMsg(g_pfnGetLogicalProcessorInformationEx(RelationGroup, pInfo, &cbInfo) != FALSE,
+                       ("last error = %u, cbInfo = %u (in %u)\n", GetLastError(), cbInfo, g_cbRtMpWinGrpRelBuf));
+        AssertFatalMsg(pInfo->Relationship == RelationGroup,
+                       ("Relationship = %u, expected %u!\n", pInfo->Relationship, RelationGroup));
+        AssertFatalMsg(pInfo->Group.MaximumGroupCount == g_cRtMpWinMaxCpuGroups,
+                       ("MaximumGroupCount is %u, expected %u!\n", pInfo->Group.MaximumGroupCount, g_cRtMpWinMaxCpuGroups));
+
+        RTCpuSetEmpty(pSet);
+        for (uint32_t idxGroup = 0; idxGroup < pInfo->Group.MaximumGroupCount; idxGroup++)
         {
-            /*
-             * Parse the result.
-             */
-            uint32_t cCores = 0;
-            uint32_t i      = cbSysProcInfo / sizeof(paSysInfo[0]);
-            while (i-- > 0)
-                if (paSysInfo[i].Relationship == RelationProcessorCore)
-                    cCores++;
-
-            RTMemFree(paSysInfo);
-            Assert(cCores > 0);
-            return cCores;
+            Assert(pInfo->Group.GroupInfo[idxGroup].MaximumProcessorCount == g_aRtMpWinCpuGroups[idxGroup].cMaxCpus);
+            Assert(pInfo->Group.GroupInfo[idxGroup].ActiveProcessorCount  <= g_aRtMpWinCpuGroups[idxGroup].cMaxCpus);
+
+            KAFFINITY fActive = pInfo->Group.GroupInfo[idxGroup].ActiveProcessorMask;
+            if (fActive != 0)
+            {
+#ifdef RT_STRICT
+                uint32_t    cMembersLeft = pInfo->Group.GroupInfo[idxGroup].ActiveProcessorCount;
+#endif
+                int const   cMembers  = g_aRtMpWinCpuGroups[idxGroup].cMaxCpus;
+                for (int idxMember = 0; idxMember < cMembers; idxMember++)
+                {
+                    if (fActive & 1)
+                    {
+#ifdef RT_STRICT
+                        cMembersLeft--;
+#endif
+                        RTCpuSetAddByIndex(pSet, g_aRtMpWinCpuGroups[idxGroup].aidxCpuSetMembers[idxMember]);
+                        fActive >>= 1;
+                        if (!fActive)
+                            break;
+                    }
+                    else
+                    {
+                        fActive >>= 1;
+                    }
+                }
+                Assert(cMembersLeft == 0);
+            }
+            else
+                Assert(pInfo->Group.GroupInfo[idxGroup].ActiveProcessorCount == 0);
         }
 
-        RTMemFree(paSysInfo);
+        return pSet;
     }
 
-    /* If we don't have the necessary API or if it failed, return the same
-       value as the generic implementation. */
-    return RTMpGetCount();
+    /*
+     * Legacy fallback code.
+     */
+    SYSTEM_INFO SysInfo;
+    GetSystemInfo(&SysInfo);
+    return RTCpuSetFromU64(pSet, SysInfo.dwActiveProcessorMask);
 }
 
 
-RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
+RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
 {
-    SYSTEM_INFO SysInfo;
-    GetSystemInfo(&SysInfo);
-/** @todo port to W2K8 / W7 w/ > 64 CPUs & grouping. */
-    return RTCpuSetFromU64(pSet, SysInfo.dwActiveProcessorMask);
+    RTCPUSET Set;
+    return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
 }
 
 
 RTDECL(RTCPUID) RTMpGetOnlineCount(void)
 {
+#ifdef IPRT_WITH_GIP_MP_INFO
+    RTMPWIN_UPDATE_GIP_GLOBALS_AND_GET_PGIP();
+    if (pGip)
+        return pGip->cOnlineCpus;
+#endif
+
     RTCPUSET Set;
     RTMpGetOnlineSet(&Set);
     return RTCpuSetCount(&Set);
@@ -181,7 +805,7 @@ RTDECL(RTCPUID) RTMpGetOnlineCount(void)
 
 RTDECL(RTCPUID) RTMpGetOnlineCoreCount(void)
 {
-    /** @todo this isn't entirely correct. */
+    /** @todo this isn't entirely correct, but whatever. */
     return RTMpGetCoreCount();
 }
 
diff --git a/src/VBox/Runtime/testcase/Makefile.kmk b/src/VBox/Runtime/testcase/Makefile.kmk
index 60db22b..9898419 100644
--- a/src/VBox/Runtime/testcase/Makefile.kmk
+++ b/src/VBox/Runtime/testcase/Makefile.kmk
@@ -236,7 +236,7 @@ tstRTBase64_SOURCES = tstRTBase64.cpp
 
 tstRTBigNum_TEMPLATE = VBOXR3TSTEXE
 tstRTBigNum_SOURCES = tstRTBigNum.cpp
-tstRTBigNum_SDKS = VBOX_OPENSSL
+tstRTBigNum_SDKS = VBOX_OPENSSL2
 
 tstRTBitOperations_TEMPLATE = VBOXR3TSTEXE
 tstRTBitOperations_SOURCES = tstRTBitOperations.cpp
diff --git a/src/VBox/Runtime/testcase/tstRTMp-1.cpp b/src/VBox/Runtime/testcase/tstRTMp-1.cpp
index 47ac0d6..50ddce4 100644
--- a/src/VBox/Runtime/testcase/tstRTMp-1.cpp
+++ b/src/VBox/Runtime/testcase/tstRTMp-1.cpp
@@ -33,10 +33,13 @@
 #include <iprt/err.h>
 #include <iprt/string.h>
 #include <iprt/test.h>
+#ifdef VBOX
+# include <VBox/sup.h>
+#endif
 
 
 
-int main()
+int main(int argc, char **argv)
 {
     RTTEST hTest;
     RTEXITCODE rcExit = RTTestInitAndCreate("tstRTMp-1", &hTest);
@@ -44,6 +47,12 @@ int main()
         return rcExit;
     RTTestBanner(hTest);
 
+    NOREF(argc); NOREF(argv);
+#ifdef VBOX
+    if (argc > 1)
+        SUPR3Init(NULL);
+#endif
+
     /*
      * Present and possible CPUs.
      */
diff --git a/src/VBox/Storage/Makefile.kmk b/src/VBox/Storage/Makefile.kmk
index f5d7c44..ddfe9cb 100644
--- a/src/VBox/Storage/Makefile.kmk
+++ b/src/VBox/Storage/Makefile.kmk
@@ -60,8 +60,7 @@ endif
 if defined(VBOX_WITH_EXTPACK_PUEL) && defined(VBOX_WITH_EXTPACK_PUEL_BUILD)
  if defined(VBOX_WITH_PLUGIN_CRYPT)
   DLLS += VDPluginCrypt
-  VDPluginCrypt_TEMPLATE      = VBoxR3ExtPackPuel
-  VDPluginCrypt_SDKS          = VBoxOpenSslExtPack
+  VDPluginCrypt_TEMPLATE      = VBoxR3ExtPackPuelWithOpenSsl
   VDPluginCrypt_LDFLAGS.linux = -Wl,--no-undefined
 
   VDPluginCrypt_SOURCES  = \
diff --git a/src/VBox/VMM/VMMAll/TMAllVirtual.cpp b/src/VBox/VMM/VMMAll/TMAllVirtual.cpp
index 1791661..b090497 100644
--- a/src/VBox/VMM/VMMAll/TMAllVirtual.cpp
+++ b/src/VBox/VMM/VMMAll/TMAllVirtual.cpp
@@ -118,6 +118,8 @@ DECLCALLBACK(DECLEXPORT(uint64_t)) tmVirtualNanoTSRediscover(PRTTIMENANOTSDATA p
                 pfnWorker = fLFence ? RTTimeNanoTSLFenceAsyncUseIdtrLim     : RTTimeNanoTSLegacyAsyncUseIdtrLim;
             else if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS)
                 pfnWorker = fLFence ? RTTimeNanoTSLFenceAsyncUseRdtscp      : RTTimeNanoTSLegacyAsyncUseRdtscp;
+            else if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL)
+                pfnWorker = fLFence ? RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl : RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl;
             else
                 pfnWorker = fLFence ? RTTimeNanoTSLFenceAsyncUseApicId      : RTTimeNanoTSLegacyAsyncUseApicId;
 #endif
diff --git a/src/VBox/VMM/VMMR3/CFGM.cpp b/src/VBox/VMM/VMMR3/CFGM.cpp
index 9079a7b..77510a2 100644
--- a/src/VBox/VMM/VMMR3/CFGM.cpp
+++ b/src/VBox/VMM/VMMR3/CFGM.cpp
@@ -3243,12 +3243,12 @@ static void cfgmR3Dump(PCFGMNODE pRoot, unsigned iLevel, PCDBGFINFOHLP pHlp)
                     || (   pLeaf->cchName >= 2
                         && !RTStrNCmp(pLeaf->szName, "cb", 2)) )
                 {
-                    if (pLeaf->Value.Integer.u64 > _2G)
-                        pHlp->pfnPrintf(pHlp, ", %'lld GB", pLeaf->Value.Integer.u64 / _1G);
-                    else if (pLeaf->Value.Integer.u64 > _2M)
+                    if (pLeaf->Value.Integer.u64 > _2M)
                         pHlp->pfnPrintf(pHlp, ", %'lld MB", pLeaf->Value.Integer.u64 / _1M);
                     else if (pLeaf->Value.Integer.u64 > _2K)
                         pHlp->pfnPrintf(pHlp, ", %'lld KB", pLeaf->Value.Integer.u64 / _1K);
+                    if (pLeaf->Value.Integer.u64 > _2G)
+                        pHlp->pfnPrintf(pHlp, ", %'lld GB", pLeaf->Value.Integer.u64 / _1G);
                 }
                 pHlp->pfnPrintf(pHlp, ")\n");
                 break;
diff --git a/src/libs/Makefile.kmk b/src/libs/Makefile.kmk
index c595c8a..f3bcdcc 100644
--- a/src/libs/Makefile.kmk
+++ b/src/libs/Makefile.kmk
@@ -39,8 +39,8 @@ endif # !VBOX_ONLY_DOCS
 
 # Libcurl for inet access
 if defined(VBOX_WITH_LIBCURL) && !defined(VBOX_ONLY_EXTPACKS_USE_IMPLIBS) && !defined(VBOX_ONLY_SDK) && !defined(VBOX_ONLY_VALIDATIONKIT) \
- && "$(SDK_VBOX_LIBCURL_INCS)" == "$(PATH_ROOT)/src/libs/curl-7.47.0/include"
- include $(PATH_SUB_CURRENT)/curl-7.47.0/Makefile.kmk
+ && "$(SDK_VBOX_LIBCURL_INCS)" == "$(PATH_ROOT)/src/libs/curl-7.50.3/include"
+ include $(PATH_SUB_CURRENT)/curl-7.50.3/Makefile.kmk
 endif
 
 # The kStuff lib used by IPRT and the debugger.
@@ -52,7 +52,7 @@ endif
 if !defined(VBOX_ONLY_SDK) \
  && (   "$(SDK_VBOX_OPENSSL_INCS)" == "$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)" \
      || defined(VBOX_WITH_EXTPACK_PUEL_BUILD))
- include $(PATH_SUB_CURRENT)/openssl-1.0.1t/Makefile.kmk
+ include $(PATH_SUB_CURRENT)/openssl-1.1.0b/Makefile.kmk
 endif
 
 # libjpeg for VRDP video redirection and ExtPack's DrvHostWebcam
diff --git a/src/libs/xpcom18a4/python/gen_python_deps.py b/src/libs/xpcom18a4/python/gen_python_deps.py
index 2c4013f..04ec739 100755
--- a/src/libs/xpcom18a4/python/gen_python_deps.py
+++ b/src/libs/xpcom18a4/python/gen_python_deps.py
@@ -12,6 +12,7 @@ VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 """
 
+from __future__ import print_function
 import os,sys
 from distutils.version import StrictVersion
 
@@ -87,7 +88,8 @@ def main(argv):
 
     if multi == 0:
         prefixes = ["/usr"]
-        versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
+        versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1]),
+                    str(sys.version_info[0])+'.'+str(sys.version_info[1])+'m']
 
     if target == 'darwin':
         ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
@@ -128,6 +130,8 @@ def main(argv):
         print_vars(vers, known[k], sep, bitness_magic)
     if d is not None:
         print_vars("DEF", known[d], sep, bitness_magic)
+    else:
+        print(argv[0] + ": No Python development package found!", file=sys.stderr)
 
 if __name__ == '__main__':
     main(sys.argv)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-virtualbox/virtualbox.git



More information about the Pkg-virtualbox-commits mailing list