Skip to content

Commit

Permalink
x86/avx: Fix fpu init logic when CPUID_XSTATE fails
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
heatd committed May 12, 2024
1 parent f4255c3 commit bde2a0b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions kernel/arch/x86_64/avx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit bde2a0b

Please sign in to comment.