Skip to content

Commit

Permalink
cpu-features: Actually fix the AVX2 detection
Browse files Browse the repository at this point in the history
We were mistakenly looking for AVX instead of AVX2.

Co-authored-by: Stefano Moioli <smxdev4@gmail.com>
  • Loading branch information
oleavr and smx-smx committed Nov 15, 2023
1 parent c4aa189 commit ed4f171
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gum/gum.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,18 +727,18 @@ static GumCpuFeatures
gum_do_query_cpu_features (void)
{
GumCpuFeatures features = 0;
gboolean cpu_supports_avx2 = FALSE;
gboolean os_enabled_xsave = FALSE;
guint a, b, c, d;

if (gum_get_cpuid (1, &a, &b, &c, &d))
{
gboolean cpu_supports_avx2, os_enabled_xsave;
if (gum_get_cpuid (7, &a, &b, &c, &d))
cpu_supports_avx2 = (b & (1 << 5)) != 0;

cpu_supports_avx2 = (c & (1 << 28)) != 0;
if (gum_get_cpuid (1, &a, &b, &c, &d))
os_enabled_xsave = (c & (1 << 27)) != 0;

if (cpu_supports_avx2 && os_enabled_xsave)
features |= GUM_CPU_AVX2;
}
if (cpu_supports_avx2 && os_enabled_xsave)
features |= GUM_CPU_AVX2;

return features;
}
Expand Down

0 comments on commit ed4f171

Please sign in to comment.