diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -238,22 +238,8 @@ fxrstor((char *)addr); } -static void -init_xsave(void) -{ - - if (use_xsave) - return; - if ((cpu_feature2 & CPUID2_XSAVE) == 0) - return; - use_xsave = 1; - TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); -} - DEFINE_IFUNC(, void, fpusave, (void *)) { - - init_xsave(); if (!use_xsave) return (fpusave_fxsave); if ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0) { @@ -266,8 +252,6 @@ DEFINE_IFUNC(, void, fpurestore, (void *)) { - - init_xsave(); if (!use_xsave) return (fpurestore_fxrstor); return ((cpu_stdext_feature & CPUID_STDEXT_NFPUSG) != 0 ? diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1345,6 +1345,11 @@ &pmap_pcid_invlpg_workaround_uena); cpu_init_small_core(); + if ((cpu_feature2 & CPUID2_XSAVE) != 0) { + use_xsave = 1; + TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); + } + link_elf_ireloc(kmdp); /* diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1545,6 +1545,11 @@ i386_kdb_init(); } + if (cpu_fxsr && (cpu_feature2 & CPUID2_XSAVE) != 0) { + use_xsave = 1; + TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); + } + kmdp = preload_search_by_type("elf kernel"); link_elf_ireloc(kmdp); @@ -1565,6 +1570,7 @@ msgbufinit(msgbufp, msgbufsize); npxinit(true); + /* * Set up thread0 pcb after npxinit calculated pcb + fpu save * area size. Zero out the extended state header in fpu save diff --git a/sys/i386/i386/npx.c b/sys/i386/i386/npx.c --- a/sys/i386/i386/npx.c +++ b/sys/i386/i386/npx.c @@ -320,22 +320,8 @@ fnsave((char *)addr); } -static void -init_xsave(void) -{ - - if (use_xsave) - return; - if (!cpu_fxsr || (cpu_feature2 & CPUID2_XSAVE) == 0) - return; - use_xsave = 1; - TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); -} - DEFINE_IFUNC(, void, fpusave, (union savefpu *)) { - - init_xsave(); if (use_xsave) return ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0 ? fpusave_xsaveopt : fpusave_xsave);