Index: trunk/src/VBox/ValidationKit/bootsectors/bs3-fpustate-1-template.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3-fpustate-1-template.c	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3-fpustate-1-template.c	(revision 104071)
@@ -186,6 +186,6 @@
     BS3PTRUNION         MmioReg;
     BS3CPUVENDOR const  enmCpuVendor            = Bs3GetCpuVendor();
-    bool const          fSkipStorIdt            = Bs3TestQueryCfgBool(VMMDEV_TESTING_CFG_IS_NEM_LINUX);
-    bool const          fMayHaveZeroStEnvSels   = Bs3TestQueryCfgBool(VMMDEV_TESTING_CFG_IS_NEM_LINUX);
+    bool const          fSkipStorIdt            = Bs3TestQueryCfgBool(VMMDEV_TESTING_CFG_IS_NEM_LINUX, false);
+    bool const          fMayHaveZeroStEnvSels   = Bs3TestQueryCfgBool(VMMDEV_TESTING_CFG_IS_NEM_LINUX, false);
     bool const          fFastFxSaveRestore      = RT_BOOL(ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_FFXSR);
     //bool const          fFdpXcptOnly       = (ASMCpuIdEx_EBX(7, 0) & X86_CPUID_STEXT_FEATURE_EBX_FDP_EXCPTN_ONLY)
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 104071)
@@ -241,4 +241,5 @@
 	bs3-cmn-TestCheckExtCtx.c \
 	bs3-cmn-TestQueryCfgU8.asm \
+	bs3-cmn-TestQueryCfgU16.asm \
 	bs3-cmn-TestQueryCfgU32.asm \
 	bs3-cmn-TestHostPrintf.c \
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestInit.c	(revision 104071)
@@ -66,13 +66,5 @@
     if (g_fbBs3VMMDevTesting)
     {
-        uint16_t uValue;
-#if ARCH_BITS == 16
-        ASMOutU16(VMMDEV_TESTING_IOPORT_CMD, (uint16_t)VMMDEV_TESTING_CMD_QUERY_CFG);
-#else
-        ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_QUERY_CFG);
-#endif
-        ASMOutU16(VMMDEV_TESTING_IOPORT_DATA, VMMDEV_TESTING_CFG_THRESHOLD_NATIVE_RECOMPILER);
-        uValue = ASMInU16(VMMDEV_TESTING_IOPORT_DATA);
-Bs3TestPrintf("VMMDEV_TESTING_CFG_THRESHOLD_NATIVE_RECOMPILER=%RU16\n", uValue);
+        uint16_t uValue = Bs3TestQueryCfgU16(VMMDEV_TESTING_CFG_THRESHOLD_NATIVE_RECOMPILER, 0);
         if (uValue > 0 && uValue < 1024)
             g_cBs3ThresholdNativeRecompiler = uValue;
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU16.asm
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU16.asm	(revision 104071)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU16.asm	(revision 104071)
@@ -0,0 +1,101 @@
+; $Id$
+;; @file
+; BS3Kit - Bs3TestQueryCfgU16.
+;
+
+;
+; Copyright (C) 2007-2023 Oracle and/or its affiliates.
+;
+; This file is part of VirtualBox base platform packages, as
+; available from https://www.virtualbox.org.
+;
+; This program is free software; you can redistribute it and/or
+; modify it under the terms of the GNU General Public License
+; as published by the Free Software Foundation, in version 3 of the
+; License.
+;
+; This program is distributed in the hope that it will be useful, but
+; WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+; General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program; if not, see <https://www.gnu.org/licenses>.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
+; in the VirtualBox 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.
+;
+; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
+;
+
+%include "bs3kit-template-header.mac"
+%include "VBox/VMMDevTesting.mac"
+
+BS3_EXTERN_DATA16 g_fbBs3VMMDevTesting
+TMPL_BEGIN_TEXT
+
+;;
+; @cproto   BS3_DECL(uint16_t) Bs3TestQueryCfgU16(uint16_t uCfg, uint16_t uDefault);
+;
+BS3_PROC_BEGIN_CMN Bs3TestQueryCfgU16, BS3_PBC_HYBRID
+        BS3_CALL_CONV_PROLOG 2
+        push    xBP
+        mov     xBP, xSP
+        push    xDX
+        push    xCX
+
+        cmp     byte [BS3_DATA16_WRT(g_fbBs3VMMDevTesting)], 0
+        je      .no_vmmdev
+
+        ; Issue the query command.
+        mov     dx, VMMDEV_TESTING_IOPORT_CMD
+%if TMPL_BITS == 16
+        mov     ax, VMMDEV_TESTING_CMD_QUERY_CFG - VMMDEV_TESTING_CMD_MAGIC_HI_WORD
+        out     dx, ax
+%else
+        mov     eax, VMMDEV_TESTING_CMD_QUERY_CFG
+        out     dx, eax
+%endif
+
+        ; Write what we wish to query.
+        mov     ax, [xBP + xCB + cbCurRetAddr]
+        mov     dx, VMMDEV_TESTING_IOPORT_DATA
+        out     dx, ax
+
+        ; Read back the result.
+        in      ax, dx
+%if TMPL_BITS == 16
+        mov     cx, ax
+        in      ax, dx                      ; read okay magic.
+        cmp     ax, VMMDEV_TESTING_QUERY_CFG_OKAY_TAIL & 0xffff
+        mov     ax, cx
+%else
+        movzx   ecx, ax
+        in      eax, dx                     ; read okay magic.
+        cmp     eax, VMMDEV_TESTING_QUERY_CFG_OKAY_TAIL
+        mov     eax, ecx
+%endif
+        jne     .no_vmmdev
+
+.return:
+        pop     xCX
+        pop     xDX
+        pop     xBP
+        BS3_CALL_CONV_EPILOG 2
+        BS3_HYBRID_RET
+
+.no_vmmdev:
+%if TMPL_BITS == 16
+        mov     ax, [xBP + xCB + cbCurRetAddr + xCB]
+%else
+        movzx   eax, word [xBP + xCB + cbCurRetAddr + xCB]
+%endif
+        jmp     .return
+BS3_PROC_END_CMN   Bs3TestQueryCfgU16
+
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU32.asm
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU32.asm	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU32.asm	(revision 104071)
@@ -1,9 +1,9 @@
 ; $Id$
 ;; @file
-; BS3Kit - Bs3TestQueryCfgU8.
+; BS3Kit - Bs3TestQueryCfgU32.
 ;
 
 ;
-; Copyright (C) 2007-2023 Oracle and/or its affiliates.
+; Copyright (C) 2007-2024 Oracle and/or its affiliates.
 ;
 ; This file is part of VirtualBox base platform packages, as
@@ -42,11 +42,12 @@
 
 ;;
-; @cproto   BS3_DECL(uint32_t) Bs3TestQueryCfgU32(uint16_t uCfg);
+; @cproto   BS3_DECL(uint32_t) Bs3TestQueryCfgU32(uint16_t uCfg, uint32_t uDefault);
 ;
 BS3_PROC_BEGIN_CMN Bs3TestQueryCfgU32, BS3_PBC_HYBRID
-        BS3_CALL_CONV_PROLOG 1
+        BS3_CALL_CONV_PROLOG 2
         push    xBP
         mov     xBP, xSP
 TNOT16  push    xDX
+        push    xCX
 
         cmp     byte [BS3_DATA16_WRT(g_fbBs3VMMDevTesting)], 0
@@ -70,23 +71,32 @@
         ; Read back the result.
 %if TMPL_BITS == 16
-        in      ax, dx
+        in      ax, dx                      ; first word
         push    ax
-        in      ax, dx
-        mov     dx, ax
+        in      ax, dx                      ; second word
+        mov     cx, ax
+        in      ax, dx                      ; okay magic following the value.
+        cmp     ax, VMMDEV_TESTING_QUERY_CFG_OKAY_TAIL & 0xffff
+        mov     dx, cx
         pop     ax
 %else
         in      eax, dx
+        mov     ecx, eax
+        in      eax, dx
+        cmp     eax, VMMDEV_TESTING_QUERY_CFG_OKAY_TAIL
+        mov     eax, ecx
 %endif
+        jne     .no_vmmdev
 
 .return:
+        pop     xCX
 TNOT16  pop     xDX
         pop     xBP
-        BS3_CALL_CONV_EPILOG 1
+        BS3_CALL_CONV_EPILOG 2
         BS3_HYBRID_RET
 
 .no_vmmdev:
-        xor     xAX, xAX
+        mov     xAX, [xBP + xCB + cbCurRetAddr + xCB]
 %if TMPL_BITS == 16
-        xor     xDX, xDX
+        mov     xDX, [xBP + xCB + cbCurRetAddr + xCB + xCB]
 %endif
         jmp     .return
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU8.asm
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU8.asm	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestQueryCfgU8.asm	(revision 104071)
@@ -42,15 +42,15 @@
 
 ;;
-; @cproto   BS3_DECL(uint8_t) Bs3TestQueryCfgU8(uint16_t uCfg);
-; @cproto   BS3_DECL(bool)    Bs3TestQueryCfgBool(uint16_t uCfg);
+; @cproto   BS3_DECL(uint8_t) Bs3TestQueryCfgU8(uint16_t uCfg, uint8_t bDefault);
+; @cproto   BS3_DECL(bool)    Bs3TestQueryCfgBool(uint16_t uCfg, bool fDefault);
 ;
 BS3_GLOBAL_NAME_EX BS3_CMN_NM(Bs3TestQueryCfgBool), function, 3
 BS3_PROC_BEGIN_CMN Bs3TestQueryCfgU8, BS3_PBC_HYBRID
-        BS3_CALL_CONV_PROLOG 1
+        BS3_CALL_CONV_PROLOG 2
         push    xBP
         mov     xBP, xSP
         push    xDX
+        push    xCX
 
-        xor     al, al
         cmp     byte [BS3_DATA16_WRT(g_fbBs3VMMDevTesting)], 0
         je      .no_vmmdev
@@ -73,10 +73,32 @@
         ; Read back the result.
         in      al, dx
+%if TMPL_BITS == 16
+        mov     cl, al
+        in      ax, dx                      ; check the 'okay'
+        cmp     ax, VMMDEV_TESTING_QUERY_CFG_OKAY_TAIL & 0xffff
+        mov     al, cl
+        mov     ah, 0
+%else
+        movzx   ecx, al
+        in      eax, dx                     ; check the 'okay'
+        cmp     eax, VMMDEV_TESTING_QUERY_CFG_OKAY_TAIL
+        mov     eax, ecx
+%endif
+        jne     .no_vmmdev
+
+.return:
+        pop     xCX
+        pop     xDX
+        pop     xBP
+        BS3_CALL_CONV_EPILOG 2
+        BS3_HYBRID_RET
 
 .no_vmmdev:
-        pop     xDX
-        pop     xBP
-        BS3_CALL_CONV_EPILOG 1
-        BS3_HYBRID_RET
+%if TMPL_BITS == 16
+        mov     al, [xBP + xCB + cbCurRetAddr + xCB]
+%else
+        movzx   eax, byte [xBP + xCB + cbCurRetAddr + xCB]
+%endif
+        jmp     .return
 BS3_PROC_END_CMN   Bs3TestQueryCfgU8
 
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk	(revision 104071)
@@ -99,4 +99,5 @@
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabAllocFixed)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabFree)
+$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestQueryCfgU16)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestSubErrorCount)
 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxGetMxCsr)
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h	(revision 104071)
@@ -208,4 +208,5 @@
 #define Bs3TestPrintfV BS3_CMN_MANGLER(Bs3TestPrintfV)
 #define Bs3TestQueryCfgBool BS3_CMN_MANGLER(Bs3TestQueryCfgBool)
+#define Bs3TestQueryCfgU16 BS3_CMN_MANGLER(Bs3TestQueryCfgU16)
 #define Bs3TestQueryCfgU32 BS3_CMN_MANGLER(Bs3TestQueryCfgU32)
 #define Bs3TestQueryCfgU8 BS3_CMN_MANGLER(Bs3TestQueryCfgU8)
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h	(revision 104071)
@@ -208,4 +208,5 @@
 #undef Bs3TestPrintfV
 #undef Bs3TestQueryCfgBool
+#undef Bs3TestQueryCfgU16
 #undef Bs3TestQueryCfgU32
 #undef Bs3TestQueryCfgU8
Index: trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 104070)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 104071)
@@ -3699,22 +3699,38 @@
  * @returns Value.
  * @param   uCfg        A VMMDEV_TESTING_CFG_XXX value.
- */
-BS3_CMN_PROTO_STUB(uint8_t, Bs3TestQueryCfgU8,(uint16_t uCfg));
-
-/**
- * Queries an unsigned 8-bit configuration value.
+ * @param   bDefault    The default value to return if the VMMDev isn't
+ *                      available or the query failed.
+ */
+BS3_CMN_PROTO_STUB(uint8_t, Bs3TestQueryCfgU8,(uint16_t uCfg, uint8_t bDefault));
+
+/**
+ * Queries a boolean configuration value.
  *
  * @returns Value.
  * @param   uCfg        A VMMDEV_TESTING_CFG_XXX value.
- */
-BS3_CMN_PROTO_STUB(bool, Bs3TestQueryCfgBool,(uint16_t uCfg));
-
-/**
- * Queries an unsigned 32-bit configuration value.
+ * @param   fDefault    The default value to return if the VMMDev isn't
+ *                      available or the query failed.
+ */
+BS3_CMN_PROTO_STUB(bool, Bs3TestQueryCfgBool,(uint16_t uCfg, bool fDefault));
+
+/**
+ * Queries an unsigned 16-bit configuration value.
  *
  * @returns Value.
  * @param   uCfg        A VMMDEV_TESTING_CFG_XXX value.
- */
-BS3_CMN_PROTO_STUB(uint32_t, Bs3TestQueryCfgU32,(uint16_t uCfg));
+ * @param   uDefault    The default value to return if the VMMDev isn't
+ *                      available or the query failed.
+ */
+BS3_CMN_PROTO_STUB(uint16_t, Bs3TestQueryCfgU16,(uint16_t uCfg, uint16_t uDefault));
+
+/**
+ * Queries an unsigned 32-bit configuration value.
+ *
+ * @returns Value.
+ * @param   uCfg        A VMMDEV_TESTING_CFG_XXX value.
+ * @param   uDefault    The default value to return if the VMMDev isn't
+ *                      available or the query failed.
+ */
+BS3_CMN_PROTO_STUB(uint32_t, Bs3TestQueryCfgU32,(uint16_t uCfg, uint32_t uDefault));
 
 /**
