bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH gnumach] fpu: Fix cpuid feature detection


From: Samuel Thibault
Subject: Re: [PATCH gnumach] fpu: Fix cpuid feature detection
Date: Sat, 27 Jan 2024 23:13:46 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Applied, thanks!

Olivier Valentin, le mer. 24 janv. 2024 09:00:19 +0100, a ecrit:
> Make sure to fetch capabilities from cpuid(0xd,0x1)
> and max structure sizes from cpuid(0xd,0x0).
> ---
>  i386/i386/fpu.c | 40 +++++++++++++++-------------------------
>  1 file 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;
>               }
> -- 
> 2.40.1
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]