Index: trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c
===================================================================
--- trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c	(revision 70662)
+++ trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c	(revision 70666)
@@ -845,6 +845,6 @@
 
 
-static void bs3CpuInstr2_rdfsbase_rdgsbase_Common(uint8_t bMode, bool fSupportsFsGsBase,
-                                                  BS3CI2FSGSBASE const *paFsGsBaseWorkers, unsigned cFsGsBaseWorkers)
+static void bs3CpuInstr2_rdfsbase_rdgsbase_Common(uint8_t bMode, BS3CI2FSGSBASE const *paFsGsBaseWorkers,
+                                                  unsigned cFsGsBaseWorkers)
 {
     BS3REGCTX         Ctx;
@@ -853,4 +853,10 @@
     unsigned          iWorker;
     unsigned          iIter;
+    uint32_t          uDummy;
+    uint32_t          uStdExtFeatEbx;
+    bool              fSupportsFsGsBase;
+
+    ASMCpuId_Idx_ECX(7, 0, &uDummy, &uStdExtFeatEbx, &uDummy, &uDummy);
+    fSupportsFsGsBase = RT_BOOL(uStdExtFeatEbx & X86_CPUID_STEXT_FEATURE_EBX_FSGSBASE);
 
     /* Ensure the structures are allocated before we sample the stack pointer. */
@@ -873,5 +879,5 @@
             bs3CpuInstr2_fsgsbase_ExpectUD(bMode, &Ctx, &ExpectCtx, &TrapFrame);
 
-            /* Read null base address. */
+            /* Read existing base address. */
             Ctx.rbx.u  = 0xa0000;
             Ctx.cr4.u |= X86_CR4_FSGSBASE;
@@ -879,5 +885,5 @@
             Bs3TrapSetJmpAndRestore(&Ctx, &TrapFrame);
             ExpectCtx.rip.u       = Ctx.rip.u + paFsGsBaseWorkers[iWorker].offWorkerUd2;
-            ExpectCtx.rbx.u       = 0;
+            ExpectCtx.rbx.u       = TrapFrame.Ctx.rbx.u;
             ExpectCtx.rflags.u32 |= X86_EFL_RF;
             if (!Bs3TestCheckRegCtxEx(&TrapFrame.Ctx, &ExpectCtx, 0 /*cbPcAdjust*/, 0 /*cbSpAdjust*/, 0 /*fExtraEfl*/, "lm64",
@@ -908,6 +914,6 @@
 
 
-static void bs3CpuInstr2_wrfsbase_wrgsbase_Common(uint8_t bMode, bool fSupportsFsGsBase,
-                                                  BS3CI2FSGSBASE const *paFsGsBaseWorkers, unsigned cFsGsBaseWorkers)
+static void bs3CpuInstr2_wrfsbase_wrgsbase_Common(uint8_t bMode, BS3CI2FSGSBASE const *paFsGsBaseWorkers,
+                                                  unsigned cFsGsBaseWorkers)
 {
     BS3REGCTX         Ctx;
@@ -916,4 +922,10 @@
     unsigned          iWorker;
     unsigned          iIter;
+    uint32_t          uDummy;
+    uint32_t          uStdExtFeatEbx;
+    bool              fSupportsFsGsBase;
+
+    ASMCpuId_Idx_ECX(7, 0, &uDummy, &uStdExtFeatEbx, &uDummy, &uDummy);
+    fSupportsFsGsBase = RT_BOOL(uStdExtFeatEbx & X86_CPUID_STEXT_FEATURE_EBX_FSGSBASE);
 
     /* Ensure the structures are allocated before we sample the stack pointer. */
@@ -972,6 +984,5 @@
 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(bs3CpuInstr2_wrfsbase)(uint8_t bMode)
 {
-    bool const fSupportFsGsBase = RT_BOOL(ASMCpuId_EBX(7) & X86_CPUID_STEXT_FEATURE_EBX_FSGSBASE);
-    bs3CpuInstr2_wrfsbase_wrgsbase_Common(bMode, fSupportFsGsBase, s_aWrFsBaseWorkers, RT_ELEMENTS(s_aWrFsBaseWorkers));
+    bs3CpuInstr2_wrfsbase_wrgsbase_Common(bMode, s_aWrFsBaseWorkers, RT_ELEMENTS(s_aWrFsBaseWorkers));
     return 0;
 }
@@ -980,6 +991,5 @@
 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(bs3CpuInstr2_wrgsbase)(uint8_t bMode)
 {
-    bool const fSupportFsGsBase = RT_BOOL(ASMCpuId_EBX(7) & X86_CPUID_STEXT_FEATURE_EBX_FSGSBASE);
-    bs3CpuInstr2_wrfsbase_wrgsbase_Common(bMode, fSupportFsGsBase, s_aWrGsBaseWorkers, RT_ELEMENTS(s_aWrGsBaseWorkers));
+    bs3CpuInstr2_wrfsbase_wrgsbase_Common(bMode, s_aWrGsBaseWorkers, RT_ELEMENTS(s_aWrGsBaseWorkers));
     return 0;
 }
@@ -988,6 +998,5 @@
 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(bs3CpuInstr2_rdfsbase)(uint8_t bMode)
 {
-    bool const fSupportFsGsBase = RT_BOOL(ASMCpuId_EBX(7) & X86_CPUID_STEXT_FEATURE_EBX_FSGSBASE);
-    bs3CpuInstr2_rdfsbase_rdgsbase_Common(bMode, fSupportFsGsBase, s_aRdFsBaseWorkers, RT_ELEMENTS(s_aRdFsBaseWorkers));
+    bs3CpuInstr2_rdfsbase_rdgsbase_Common(bMode, s_aRdFsBaseWorkers, RT_ELEMENTS(s_aRdFsBaseWorkers));
     return 0;
 }
@@ -996,6 +1005,5 @@
 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(bs3CpuInstr2_rdgsbase)(uint8_t bMode)
 {
-    bool const fSupportFsGsBase = RT_BOOL(ASMCpuId_EBX(7) & X86_CPUID_STEXT_FEATURE_EBX_FSGSBASE);
-    bs3CpuInstr2_rdfsbase_rdgsbase_Common(bMode, fSupportFsGsBase, s_aRdGsBaseWorkers, RT_ELEMENTS(s_aRdGsBaseWorkers));
+    bs3CpuInstr2_rdfsbase_rdgsbase_Common(bMode, s_aRdGsBaseWorkers, RT_ELEMENTS(s_aRdGsBaseWorkers));
     return 0;
 }
