diff options
author | Olivier Valentin <valentio@free.fr> | 2024-01-24 09:00:19 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-01-27 23:13:38 +0100 |
commit | f8d0f98e80b3d7d9b24fa077818113fb0f4b3970 (patch) | |
tree | 33cb9080b267fb66a7793d7499a53b9c2bd265cd | |
parent | eaa2f2c1bfe738d9a53c2f8ab9fbc96c2976f727 (diff) | |
download | gnumach-f8d0f98e80b3d7d9b24fa077818113fb0f4b3970.tar.gz gnumach-f8d0f98e80b3d7d9b24fa077818113fb0f4b3970.tar.bz2 gnumach-f8d0f98e80b3d7d9b24fa077818113fb0f4b3970.zip |
fpu: Fix cpuid feature detection
Make sure to fetch capabilities from cpuid(0xd,0x1)
and max structure sizes from cpuid(0xd,0x0).
Message-ID: <20240124080019.8136-1-valentio@free.fr>
-rw-r--r-- | i386/i386/fpu.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index fefe5e49..9bf5aecf 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -174,36 +174,26 @@ init_fpu(void) set_xcr0(fp_xsave_support); #endif /* MACH_RING1 */ + fp_xsave_size = offsetof(struct i386_fpsave_state, xfp_save_state) + ebx; + + if (fp_xsave_size < sizeof(struct i386_fpsave_state)) + panic("CPU-provided xstate size %d " + "is smaller than our minimum %d!\n", + fp_xsave_size, + (int) sizeof(struct i386_fpsave_state)); + eax = 0xd; ecx = 0x1; cpuid(eax, ebx, ecx, edx); - if (eax & CPU_FEATURE_XSAVES) { - fp_xsave_size = offsetof(struct i386_fpsave_state, xfp_save_state) + ebx; - if (fp_xsave_size < sizeof(struct i386_fpsave_state)) - panic("CPU-provided xstate size %d " - "is smaller than our minimum %d!\n", - fp_xsave_size, - (int) sizeof(struct i386_fpsave_state)); + if (eax & CPU_FEATURE_XSAVES) fp_save_kind = FP_XSAVES; - } else { - eax = 0xd; - ecx = 0x0; - cpuid(eax, ebx, ecx, edx); - fp_xsave_size = offsetof(struct i386_fpsave_state, xfp_save_state) + ebx; - if(fp_xsave_size < sizeof(struct i386_fpsave_state)) - panic("CPU-provided xstate size %d " - "is smaller than our minimum %d!\n", - fp_xsave_size, - (int) sizeof(struct i386_fpsave_state)); - - if (eax & CPU_FEATURE_XSAVEOPT) - fp_save_kind = FP_XSAVEOPT; - else if (eax & CPU_FEATURE_XSAVEC) - fp_save_kind = FP_XSAVEC; - else - fp_save_kind = FP_XSAVE; - } + else if (eax & CPU_FEATURE_XSAVEOPT) + fp_save_kind = FP_XSAVEOPT; + else if (eax & CPU_FEATURE_XSAVEC) + fp_save_kind = FP_XSAVEC; + else + fp_save_kind = FP_XSAVE; fp_kind = FP_387X; } |