git: b40ed1134d67 - stable/14 - x86: test the right CPUID bit when checking for XSAVEOPT support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 02 Apr 2024 08:59:40 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=b40ed1134d6763ef8a24f6fe2f0f219dba5d3f6e
commit b40ed1134d6763ef8a24f6fe2f0f219dba5d3f6e
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-03-25 10:34:06 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-02 08:58:20 +0000
x86: test the right CPUID bit when checking for XSAVEOPT support
(cherry picked from commit 960d151eaa1ecde109accc30ca0c3306551d8e58)
---
sys/amd64/amd64/fpu.c | 5 ++++-
sys/i386/i386/npx.c | 8 ++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index 3432e62bf7f8..63fcf7b0a361 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -236,9 +236,12 @@ fpurestore_fxrstor(void *addr)
DEFINE_IFUNC(, void, fpusave, (void *))
{
+ u_int cp[4];
+
if (!use_xsave)
return (fpusave_fxsave);
- if ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0) {
+ cpuid_count(0xd, 0x1, cp);
+ if ((cp[0] & CPUID_EXTSTATE_XSAVEOPT) != 0) {
return ((cpu_stdext_feature & CPUID_STDEXT_NFPUSG) != 0 ?
fpusave_xsaveopt64 : fpusave_xsaveopt3264);
}
diff --git a/sys/i386/i386/npx.c b/sys/i386/i386/npx.c
index 26def3f433f1..9cbb1340e9d1 100644
--- a/sys/i386/i386/npx.c
+++ b/sys/i386/i386/npx.c
@@ -317,9 +317,13 @@ fpusave_fnsave(union savefpu *addr)
DEFINE_IFUNC(, void, fpusave, (union savefpu *))
{
- if (use_xsave)
- return ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0 ?
+ u_int cp[4];
+
+ if (use_xsave) {
+ cpuid_count(0xd, 0x1, cp);
+ return ((cp[0] & CPUID_EXTSTATE_XSAVEOPT) != 0 ?
fpusave_xsaveopt : fpusave_xsave);
+ }
if (cpu_fxsr)
return (fpusave_fxsave);
return (fpusave_fnsave);