kernel - Zen 2 - Make sure %fs's selector is loaded in AP bootstrap
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 11 Jul 2019 06:57:02 +0000 (23:57 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 11 Jul 2019 06:57:02 +0000 (23:57 -0700)
* Issue load_fs() in the AP bootstrap.  It appears that Zen 2 handles
  %fs in a weird way when the selector isn't loaded, causing the first
  wrmsr(MSR_FSBASE) to quietly fail, and possibly others too.

* For good measure, also issue load_ds() and load_es().

* Fixes DragonFlyBSD's boot on Zen 2.

sys/platform/pc64/x86_64/mp_machdep.c

index 4a312d3..af7d4eb 100644 (file)
@@ -136,6 +136,7 @@ int current_postcode;
 /** XXX FIXME: what system files declare these??? */
 
 extern int naps;
+extern int _udatasel;
 
 int64_t tsc0_offset;
 extern int64_t tsc_offsets[];
@@ -269,6 +270,10 @@ init_secondary(void)
 
        lidt(&r_idt_arr[mdcpu->mi.gd_cpuid]);
 
+       load_ds(_udatasel);
+       load_es(_udatasel);
+       load_fs(_udatasel);
+
 #if 0
        lldt(_default_ldt);
        mdcpu->gd_currentldt = _default_ldt;