Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 66206)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 66214)
@@ -108,4 +108,10 @@
        bs3-cmn-RegCtxSetRipCsFromFlat.c \
        bs3-cmn-RegCtxSetRipCsFromLnkPtr.c \
+       bs3-cmn-ExtCtxInit.c \
+       bs3-cmn-ExtCtxSave.asm \
+       bs3-cmn-ExtCtxRestore.asm \
+       bs3-cmn-ExtCtxGetSize.c \
+       bs3-cmn-ExtCtxAlloc.c \
+       bs3-cmn-ExtCtxFree.c \
        bs3-cmn-SelFar32ToFlat32.c \
        bs3-cmn-SelFar32ToFlat32NoClobber.asm \
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxAlloc.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxAlloc.c	(revision 66214)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxAlloc.c	(revision 66214)
@@ -0,0 +1,43 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3ExtCtxAlloc
+ */
+
+/*
+ * Copyright (C) 2007-2017 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 "bs3kit-template-header.h"
+
+
+#undef Bs3ExtCtxAlloc
+BS3_CMN_DEF(PBS3EXTCTX, Bs3ExtCtxAlloc,(uint16_t fFlags, BS3MEMKIND enmKind))
+{
+    uint16_t   cbExtCtx = Bs3ExtCtxGetSize(fFlags);
+    PBS3EXTCTX pExtCtx = (PBS3EXTCTX)Bs3MemAlloc(enmKind, cbExtCtx);
+    if (pExtCtx)
+        return Bs3ExtCtxInit(pExtCtx, cbExtCtx, fFlags);
+    return NULL;
+}
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxFree.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxFree.c	(revision 66214)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxFree.c	(revision 66214)
@@ -0,0 +1,46 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3ExtCtxFree
+ */
+
+/*
+ * Copyright (C) 2007-2017 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 "bs3kit-template-header.h"
+
+
+#undef Bs3ExtCtxFree
+BS3_CMN_DEF(void, Bs3ExtCtxFree,(PBS3EXTCTX pExtCtx))
+{
+    if (pExtCtx)
+    {
+        if (pExtCtx->u16Magic == BS3EXTCTX_MAGIC)
+        {
+            pExtCtx->u16Magic = ~BS3EXTCTX_MAGIC;
+            Bs3MemFree(pExtCtx, pExtCtx->cb);
+        }
+    }
+}
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxGetSize.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxGetSize.c	(revision 66214)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxGetSize.c	(revision 66214)
@@ -0,0 +1,53 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3ExtCtxGetSize
+ */
+
+/*
+ * Copyright (C) 2007-2017 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 "bs3kit-template-header.h"
+#include <iprt/asm-amd64-x86.h>
+
+
+#undef Bs3ExtCtxGetSize
+BS3_CMN_DEF(uint16_t, Bs3ExtCtxGetSize,(uint16_t fFlags))
+{
+    uint32_t fEcx, fEdx;
+    BS3_ASSERT(fFlags == 0);
+
+    ASMCpuIdExSlow(1, 0, 0, 0, NULL, NULL, &fEcx, &fEdx);
+    if (fEcx & X86_CPUID_FEATURE_ECX_XSAVE)
+    {
+        ASMCpuIdExSlow(13, 0, 0, 0, NULL, NULL, &fEcx, NULL);
+        if (   fEcx >= sizeof(X86FXSTATE) + sizeof(X86XSAVEHDR)
+            && fEcx < _32K)
+            return RT_OFFSETOF(BS3EXTCTX, Ctx) + RT_ALIGN(fEcx, 256);
+    }
+    if (fEdx & X86_CPUID_FEATURE_EDX_FXSR)
+        return RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE);
+    return RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FPUSTATE);
+}
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxInit.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxInit.c	(revision 66214)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxInit.c	(revision 66214)
@@ -0,0 +1,54 @@
+/* $Id$ */
+/** @file
+ * BS3Kit - Bs3ExtCtxInit
+ */
+
+/*
+ * Copyright (C) 2007-2017 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 "bs3kit-template-header.h"
+#include <iprt/asm-amd64-x86.h>
+
+
+#undef Bs3ExtCtxInit
+BS3_CMN_DEF(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint16_t fFlags))
+{
+    BS3_ASSERT(fFlags == 0);
+
+    Bs3MemSet(pExtCtx, 0, cbExtCtx);
+    if (cbExtCtx >= RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE) + sizeof(X86XSAVEHDR))
+        pExtCtx->enmMethod = BS3EXTCTXMETHOD_XSAVE;
+    else if (cbExtCtx >= RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE))
+        pExtCtx->enmMethod = BS3EXTCTXMETHOD_FXSAVE;
+    else
+    {
+        BS3_ASSERT(cbExtCtx >= RT_OFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FPUSTATE));
+        pExtCtx->enmMethod = BS3EXTCTXMETHOD_ANCIENT;
+    }
+    pExtCtx->cb       = cbExtCtx;
+    pExtCtx->u16Magic = BS3EXTCTX_MAGIC;
+    return pExtCtx;
+}
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxRestore.asm
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxRestore.asm	(revision 66214)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxRestore.asm	(revision 66214)
@@ -0,0 +1,104 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3ExtCtxRestore.
+;
+
+;
+; Copyright (C) 2007-2017 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.
+;
+
+%include "bs3kit-template-header.mac"
+
+
+;;
+; Restores the extended CPU context (FPU, SSE, AVX, ++).
+;
+; @param    pExtCtx
+;
+BS3_PROC_BEGIN_CMN Bs3ExtCtxRestore, BS3_PBC_NEAR
+        push    xBP
+        mov     xBP, xSP
+        push    xAX
+BONLY32 push    xCX
+BONLY16 push    es
+BONLY16 push    bx
+
+%if ARCH_BITS == 16
+        les     bx, [xBP + xCB + cbCurRetAddr]
+        mov     al, [es:bx + BS3EXTCTX.enmMethod]
+        cmp     al, BS3EXTCTXMETHOD_XSAVE
+        je      .do_16_xsave
+        cmp     al, BS3EXTCTXMETHOD_FXSAVE
+        je      .do_16_fxsave
+        cmp     al, BS3EXTCTXMETHOD_ANCIENT
+        je      .do_16_ancient
+        int3
+
+.do_16_ancient:
+        frstor  [es:bx + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_16_xsave:
+        xrstor  [es:bx + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_16_fxsave:
+        fxrstor  [es:bx + BS3EXTCTX.Ctx]
+        ;jmp     .return
+
+%else
+BONLY32 mov     ecx, [xBP + xCB + cbCurRetAddr]
+
+        mov     al, [xCX + BS3EXTCTX.enmMethod]
+        cmp     al, BS3EXTCTXMETHOD_XSAVE
+        je      .do_xsave
+        cmp     al, BS3EXTCTXMETHOD_FXSAVE
+        je      .do_fxsave
+        cmp     al, BS3EXTCTXMETHOD_ANCIENT
+        je      .do_ancient
+        int3
+
+.do_ancient:
+        frstor  [xCX + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_xsave:
+BONLY32 xrstor  [xCX + BS3EXTCTX.Ctx]
+BONLY64 xrstor64 [xCX + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_fxsave:
+BONLY32 fxrstor [xCX + BS3EXTCTX.Ctx]
+BONLY64 fxrstor64 [xCX + BS3EXTCTX.Ctx]
+        ;jmp     .return
+
+%endif
+
+.return:
+BONLY16 pop     bx
+BONLY16 pop     es
+BONLY32 pop     xCX
+        pop     xAX
+        mov     xSP, xBP
+        pop     xBP
+        ret
+BS3_PROC_END_CMN   Bs3ExtCtxRestore
+
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxSave.asm
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxSave.asm	(revision 66214)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxSave.asm	(revision 66214)
@@ -0,0 +1,103 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3ExtCtxSave.
+;
+
+;
+; Copyright (C) 2007-2017 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.
+;
+
+%include "bs3kit-template-header.mac"
+
+
+;;
+; Saves the extended CPU context (FPU, SSE, AVX, ++).
+;
+; @param    pExtCtx
+;
+BS3_PROC_BEGIN_CMN Bs3ExtCtxSave, BS3_PBC_NEAR
+        push    xBP
+        mov     xBP, xSP
+        push    xAX
+BONLY32 push    xCX
+BONLY16 push    es
+BONLY16 push    bx
+
+%if ARCH_BITS == 16
+        les     bx, [xBP + xCB + cbCurRetAddr]
+        mov     al, [es:bx + BS3EXTCTX.enmMethod]
+        cmp     al, BS3EXTCTXMETHOD_XSAVE
+        je      .do_16_xsave
+        cmp     al, BS3EXTCTXMETHOD_FXSAVE
+        je      .do_16_fxsave
+        cmp     al, BS3EXTCTXMETHOD_ANCIENT
+        je      .do_16_ancient
+        int3
+
+.do_16_ancient:
+        fnsave  [es:bx + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_16_xsave:
+        xsave   [es:bx + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_16_fxsave:
+        fxsave  [es:bx + BS3EXTCTX.Ctx]
+        ;jmp     .return
+
+%else
+BONLY32 mov     ecx, [xBP + xCB + cbCurRetAddr]
+
+        mov     al, [xCX + BS3EXTCTX.enmMethod]
+        cmp     al, BS3EXTCTXMETHOD_XSAVE
+        je      .do_xsave
+        cmp     al, BS3EXTCTXMETHOD_FXSAVE
+        je      .do_fxsave
+        cmp     al, BS3EXTCTXMETHOD_ANCIENT
+        je      .do_ancient
+        int3
+
+.do_ancient:
+        fnsave  [xCX + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_xsave:
+BONLY32 xsave   [xCX + BS3EXTCTX.Ctx]
+BONLY64 xsave64 [xCX + BS3EXTCTX.Ctx]
+        jmp     .return
+
+.do_fxsave:
+BONLY32 fxsave  [xCX + BS3EXTCTX.Ctx]
+BONLY64 fxsave64 [xCX + BS3EXTCTX.Ctx]
+        ;jmp     .return
+
+%endif
+
+.return:
+BONLY16 pop     bx
+BONLY16 pop     es
+BONLY32 pop     xCX
+        pop     xAX
+        mov     xSP, xBP
+        pop     xBP
+        ret
+BS3_PROC_END_CMN   Bs3ExtCtxSave
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk	(revision 66206)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk	(revision 66214)
@@ -39,15 +39,17 @@
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestFailedV)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3StrCpy)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3GetModeName)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3GetModeNameShortLower)
-$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3GetModeName)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingAlias)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingInitRootForLM)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingInitRootForPAE)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingInitRootForPP)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingProtect)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingProtectPtr)
-$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingProtect)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingQueryAddressInfo)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingUnalias)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SwitchFromV86To16BitAndCallC)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxAlloc)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxInit)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetHandler)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Printf)
@@ -58,4 +60,5 @@
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3StrPrintf)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3StrPrintfV)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxGetSize)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PicUpdateMask)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabFree)
@@ -72,8 +75,11 @@
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingGetPte)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PagingSetupCanonicalTraps)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabAlloc)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabAllocEx)
-$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabAlloc)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabListAlloc)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabListAllocEx)
-$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabListAlloc)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxFree)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxRestore)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxSave)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemFree)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemGuardedTestPageFree)
@@ -108,6 +114,6 @@
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestSubV)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestTerm)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Trap16Init)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Trap16InitEx)
-$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Trap16Init)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Trap16SetGate)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Trap32Init)
@@ -118,6 +124,6 @@
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapPrintFrame)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapReInit)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapRmV86Init)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapRmV86InitEx)
-$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapRmV86Init)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapRmV86SetGate)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetHandlerEx)
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h	(revision 66206)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h	(revision 66214)
@@ -31,4 +31,10 @@
 #define Bs3A20EnableViaKbd BS3_CMN_MANGLER(Bs3A20EnableViaKbd)
 #define Bs3A20EnableViaPortA BS3_CMN_MANGLER(Bs3A20EnableViaPortA)
+#define Bs3ExtCtxAlloc BS3_CMN_MANGLER(Bs3ExtCtxAlloc)
+#define Bs3ExtCtxFree BS3_CMN_MANGLER(Bs3ExtCtxFree)
+#define Bs3ExtCtxGetSize BS3_CMN_MANGLER(Bs3ExtCtxGetSize)
+#define Bs3ExtCtxInit BS3_CMN_MANGLER(Bs3ExtCtxInit)
+#define Bs3ExtCtxRestore BS3_CMN_MANGLER(Bs3ExtCtxRestore)
+#define Bs3ExtCtxSave BS3_CMN_MANGLER(Bs3ExtCtxSave)
 #define Bs3GetModeName BS3_CMN_MANGLER(Bs3GetModeName)
 #define Bs3GetModeNameShortLower BS3_CMN_MANGLER(Bs3GetModeNameShortLower)
@@ -149,6 +155,6 @@
 #define Bs3TrapSetHandler BS3_CMN_MANGLER(Bs3TrapSetHandler)
 #define Bs3TrapSetHandlerEx BS3_CMN_MANGLER(Bs3TrapSetHandlerEx)
+#define Bs3TrapSetJmp BS3_CMN_MANGLER(Bs3TrapSetJmp)
 #define Bs3TrapSetJmpAndRestore BS3_CMN_MANGLER(Bs3TrapSetJmpAndRestore)
-#define Bs3TrapSetJmp BS3_CMN_MANGLER(Bs3TrapSetJmp)
 #define Bs3TrapUnsetJmp BS3_CMN_MANGLER(Bs3TrapUnsetJmp)
 #define Bs3UInt32Div BS3_CMN_MANGLER(Bs3UInt32Div)
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h	(revision 66206)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h	(revision 66214)
@@ -31,4 +31,10 @@
 #undef Bs3A20EnableViaKbd
 #undef Bs3A20EnableViaPortA
+#undef Bs3ExtCtxAlloc
+#undef Bs3ExtCtxFree
+#undef Bs3ExtCtxGetSize
+#undef Bs3ExtCtxInit
+#undef Bs3ExtCtxRestore
+#undef Bs3ExtCtxSave
 #undef Bs3GetModeName
 #undef Bs3GetModeNameShortLower
@@ -149,6 +155,6 @@
 #undef Bs3TrapSetHandler
 #undef Bs3TrapSetHandlerEx
+#undef Bs3TrapSetJmp
 #undef Bs3TrapSetJmpAndRestore
-#undef Bs3TrapSetJmp
 #undef Bs3TrapUnsetJmp
 #undef Bs3UInt32Div
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 66206)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 66214)
@@ -2655,4 +2655,107 @@
 
 /**
+ * The method to be used to save and restore the extended context.
+ */
+typedef enum BS3EXTCTXMETHOD
+{
+    BS3EXTCTXMETHOD_INVALID = 0,
+    BS3EXTCTXMETHOD_ANCIENT,    /**< Ancient fnsave/frstor format. */
+    BS3EXTCTXMETHOD_FXSAVE,     /**< fxsave/fxrstor format. */
+    BS3EXTCTXMETHOD_XSAVE,      /**< xsave/xrstor format. */
+    BS3EXTCTXMETHOD_END,
+} BS3EXTCTXMETHOD;
+
+
+/**
+ * Extended CPU context (FPU, SSE, AVX, ++).
+ *
+ * @remarks Also in bs3kit.inc
+ */
+typedef struct BS3EXTCTX
+{
+    /** Dummy/magic value. */
+    uint16_t            u16Magic;
+    /** The size of the structure. */
+    uint16_t            cb;
+    /** The method used to save and restore the context (BS3EXTCTXMETHOD). */
+    uint8_t             enmMethod;
+
+    /** Explicit alignment padding. */
+    uint8_t             abPadding[64 - 2 - 2 - 1];
+
+    /** The context, variable size (see above).
+     * This must be aligned on a 64 byte boundrary. */
+    union
+    {
+        /** fnsave/frstor. */
+        X86FPUSTATE     Ancient;
+        /** fxsave/fxrstor   */
+        X86FXSTATE      x87;
+        /** xsave/xrstor   */
+        X86XSAVEAREA    x;
+    } Ctx;
+} BS3EXTCTX;
+AssertCompileMemberAlignment(BS3EXTCTX, Ctx, 64);
+/** Pointer to an extended CPU context. */
+typedef BS3EXTCTX BS3_FAR *PBS3EXTCTX;
+/** Pointer to a const extended CPU context. */
+typedef BS3EXTCTX const BS3_FAR *PCBS3EXTCTX;
+
+/** Magic value for BS3EXTCTX. */
+#define BS3EXTCTX_MAGIC     UINT16_C(0x1980)
+
+/**
+ * Allocates and initializes the extended CPU context structure.
+ *
+ * @returns The new extended CPU context structure.
+ * @param   fFlags          Flags, MBZ.
+ * @param   enmKind         The kind of allocation to make.
+ */
+BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxAlloc,(uint16_t fFlags, BS3MEMKIND enmKind));
+
+/**
+ * Frees an extended CPU context structure.
+ *
+ * @param   pExtCtx         The extended CPU context (returned by
+ *                          Bs3ExtCtxAlloc).
+ */
+BS3_CMN_PROTO_STUB(void,       Bs3ExtCtxFree,(PBS3EXTCTX pExtCtx));
+
+/**
+ * Get the size required for a BS3EXTCTX structure.
+ *
+ * @returns size in bytes of the whole structure.
+ * @note    Use Bs3ExtCtxAlloc when possible.
+ */
+BS3_CMN_PROTO_STUB(uint16_t,   Bs3ExtCtxGetSize,(uint16_t fFlags));
+
+/**
+ * Initializes the extended CPU context structure.
+ * @returns pExtCtx
+ * @param   pExtCtx         The extended CPU context.
+ * @param   cbExtCtx        The size of the @a pExtCtx allocation.
+ * @param   fFlags          Flags, MBZ.
+ */
+BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint16_t fFlags));
+
+/**
+ * Saves the extended CPU state to the given structure.
+ *
+ * @param   pExtCtx         The extended CPU context.
+ * @remarks All GPRs preserved.
+ */
+BS3_CMN_PROTO_STUB(void,       Bs3ExtCtxSave,(PBS3EXTCTX pExtCtx));
+
+/**
+ * Restores the extended CPU state from the given structure.
+ *
+ * @param   pExtCtx         The extended CPU context.
+ * @remarks All GPRs preserved.
+ */
+BS3_CMN_PROTO_STUB(void,       Bs3ExtCtxRestore,(PBS3EXTCTX pExtCtx));
+
+
+
+/**
  * Trap frame.
  */
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 66206)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 66214)
@@ -1417,4 +1417,19 @@
 ;; @}
 
+
+;;
+; BS3 extended register context (FPU, SSE, AVX, ++)
+;
+struc BS3EXTCTX
+        .u16Magic   resw 1              ; uint16_t            u16Magic;
+        .cb         resw 1              ; uint16_t            cb;
+        .enmMethod  resb 1              ; uint8_t             enmMethod;
+        alignb 64
+        .Ctx        resb 512
+endstruc
+%define BS3EXTCTXMETHOD_ANCIENT     1
+%define BS3EXTCTXMETHOD_FXSAVE      2
+%define BS3EXTCTXMETHOD_XSAVE       3
+
 ;;
 ; BS3 Trap Frame.
