The KMSAN instrumentation requires some thread-local storage to maintain
state for function parameters and return values. This buffer is checked
as part of each function's prologue. It is provided by the KMSAN
runtime, which looks up a pointer in the current thread's structure.
init_secondary() is instrumented, but it runs without a valid %gs
descriptor for some time, so the runtime cannot safely access curthread.
To work around this, load GSBASE before calling init_secondary(). Then
the runtime can check curthread == NULL and simply return a pointer to
some dummy storage.
Also change init_secondary() to initialize kernelGSBASE to 0. I don't
see any reason why we have to set it to the pcpu pointer.
Sponsored by: The FreeBSD Foundation