From bde2a0b4cf31be04952cfc46da787b22c9dbfba6 Mon Sep 17 00:00:00 2001 From: Pedro Falcato Date: Sun, 12 May 2024 23:15:20 +0100 Subject: [PATCH] x86/avx: Fix fpu init logic when CPUID_XSTATE fails This should not fail if X86_FEATURE_XSAVE, but it does on an i5-3470 for reasons unknown. Handle it for the time being. Signed-off-by: Pedro Falcato --- kernel/arch/x86_64/avx.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kernel/arch/x86_64/avx.cpp b/kernel/arch/x86_64/avx.cpp index 8b8b9fa79..3164c5ef2 100644 --- a/kernel/arch/x86_64/avx.cpp +++ b/kernel/arch/x86_64/avx.cpp @@ -50,13 +50,12 @@ void avx_init() uint32_t eax, ebx, ecx, edx; ecx = 0; - if (!__get_cpuid_count(CPUID_XSTATE, 0, &eax, &ebx, &ecx, &edx)) - return; - - fpu_area_size = ebx; - fpu_area_alignment = AVX_SAVE_ALIGNMENT; - - static_branch_enable(&avx_supported); + if (__get_cpuid_count(CPUID_XSTATE, 0, &eax, &ebx, &ecx, &edx)) + { + fpu_area_size = ebx; + fpu_area_alignment = AVX_SAVE_ALIGNMENT; + static_branch_enable(&avx_supported); + } } fpu_init_cache();