git: 7f7e8fd3fe7b - stable/13 - x86: initialize use_xsave once
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Apr 2023 00:38:22 UTC
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=7f7e8fd3fe7b2edba5d90ed5bae25a1a5a8a3ca1
commit 7f7e8fd3fe7b2edba5d90ed5bae25a1a5a8a3ca1
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-04-18 15:50:26 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-04-25 00:27:27 +0000
x86: initialize use_xsave once
(cherry picked from commit 617a11eab6337693eae9d160453adf1943ab6a37)
---
sys/amd64/amd64/fpu.c | 16 ----------------
sys/amd64/amd64/machdep.c | 5 +++++
sys/i386/i386/machdep.c | 6 ++++++
sys/i386/i386/npx.c | 14 --------------
4 files changed, 11 insertions(+), 30 deletions(-)
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index f51c042bf8de..38058f4d3e57 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -260,22 +260,8 @@ fpurestore_fxrstor(void *addr)
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) {
@@ -288,8 +274,6 @@ DEFINE_IFUNC(, void, fpusave, (void *))
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
index c27e15c7e1a4..0a21dba19ff0 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1353,6 +1353,11 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
&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
index 97b095337852..f32fba72271a 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1550,6 +1550,11 @@ init386(int first)
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);
@@ -1570,6 +1575,7 @@ init386(int first)
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
index 86291ae9b96b..d9af3f7bf965 100644
--- a/sys/i386/i386/npx.c
+++ b/sys/i386/i386/npx.c
@@ -341,22 +341,8 @@ fpusave_fnsave(union savefpu *addr)
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);