diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-01-21 11:12:30 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-01-22 10:15:46 -0800 |
commit | 5f478eb0fb2b22204d501b6721c6fe9dc1f3ebba (patch) | |
tree | db8fd2d6b362dfd4d6f37c8cdc82ee130510f4fd /sysdeps/x86 | |
parent | f5432595008a4bf0158b27d90500b2d15fc74482 (diff) | |
download | glibc-5f478eb0fb2b22204d501b6721c6fe9dc1f3ebba.zip glibc-5f478eb0fb2b22204d501b6721c6fe9dc1f3ebba.tar.gz glibc-5f478eb0fb2b22204d501b6721c6fe9dc1f3ebba.tar.bz2 |
x86: Properly match CPU features in /proc/cpuinfo [BZ #27222]
Search " YYY " and " YYY\n", instead of "YYY", to avoid matching
"XXXYYYZZZ" with "YYY".
Update /proc/cpuinfo CPU feature names:
/proc/cpuinfo glibc
------------------------------------------------
avx512vbmi AVX512_VBMI
dts DS
pni SSE3
tsc_deadline_timer TSC_DEADLINE
Diffstat (limited to 'sysdeps/x86')
-rw-r--r-- | sysdeps/x86/tst-cpu-features-cpuinfo.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/sysdeps/x86/tst-cpu-features-cpuinfo.c b/sysdeps/x86/tst-cpu-features-cpuinfo.c index 771771c..3c2fa7d 100644 --- a/sysdeps/x86/tst-cpu-features-cpuinfo.c +++ b/sysdeps/x86/tst-cpu-features-cpuinfo.c @@ -53,30 +53,47 @@ get_cpuinfo (void) } int -check_proc (const char *proc_name, int flag, int usable, const char *name) +check_proc (const char *proc_name, const char *search_name, int flag, + int usable, const char *name) { int found = 0; printf ("Checking %s:\n", name); - if (!usable) + printf (" %s: %d\n", name, flag); + char *str = strstr (cpu_flags, search_name); + if (str == NULL) { - printf (" %s: insufficient usable info, skipped\n", name); - return 0; + /* If searching for " XXX " failed, try " XXX\n". */ + size_t len = strlen (search_name); + char buffer[80]; + if (len >= sizeof buffer) + abort (); + memcpy (buffer, search_name, len + 1); + buffer[len - 1] = '\n'; + str = strstr (cpu_flags, buffer); } - printf (" %s: %d\n", name, flag); - if (strstr (cpu_flags, proc_name) != NULL) + if (str != NULL) found = 1; printf (" cpuinfo (%s): %d\n", proc_name, found); if (found != flag) - printf (" *** failure ***\n"); + { + if (found || usable) + printf (" *** failure ***\n"); + else + { + printf (" *** missing in /proc/cpuinfo ***\n"); + return 0; + } + } return (found != flag); } #define CHECK_PROC(str, name) \ - check_proc (#str, HAS_CPU_FEATURE (name), CPU_FEATURE_USABLE (name), \ - "HAS_CPU_FEATURE (" #name ")"); + check_proc (#str, " "#str" ", HAS_CPU_FEATURE (name), \ + CPU_FEATURE_USABLE (name), \ + "HAS_CPU_FEATURE (" #name ")") static int do_test (int argc, char **argv) @@ -99,7 +116,7 @@ do_test (int argc, char **argv) fails += CHECK_PROC (avx512_bf16, AVX512_BF16); fails += CHECK_PROC (avx512_bitalg, AVX512_BITALG); fails += CHECK_PROC (avx512ifma, AVX512_IFMA); - fails += CHECK_PROC (avx512_vbmi, AVX512_VBMI); + fails += CHECK_PROC (avx512vbmi, AVX512_VBMI); fails += CHECK_PROC (avx512_vbmi2, AVX512_VBMI2); fails += CHECK_PROC (avx512_vnni, AVX512_VNNI); fails += CHECK_PROC (avx512_vp2intersect, AVX512_VP2INTERSECT); @@ -125,7 +142,7 @@ do_test (int argc, char **argv) fails += CHECK_PROC (dca, DCA); fails += CHECK_PROC (de, DE); fails += CHECK_PROC (zero_fcs_fds, DEPR_FPU_CS_DS); - fails += CHECK_PROC (ds, DS); + fails += CHECK_PROC (dts, DS); fails += CHECK_PROC (ds_cpl, DS_CPL); fails += CHECK_PROC (dtes64, DTES64); fails += CHECK_PROC (est, EIST); @@ -206,7 +223,7 @@ do_test (int argc, char **argv) fails += CHECK_PROC (ssbd, SSBD); fails += CHECK_PROC (sse, SSE); fails += CHECK_PROC (sse2, SSE2); - fails += CHECK_PROC (sse3, SSE3); + fails += CHECK_PROC (pni, SSE3); fails += CHECK_PROC (sse4_1, SSE4_1); fails += CHECK_PROC (sse4_2, SSE4_2); fails += CHECK_PROC (sse4a, SSE4A); @@ -223,7 +240,7 @@ do_test (int argc, char **argv) fails += CHECK_PROC (intel_pt, TRACE); fails += CHECK_PROC (tsc, TSC); fails += CHECK_PROC (tsc_adjust, TSC_ADJUST); - fails += CHECK_PROC (tsc_deadline, TSC_DEADLINE); + fails += CHECK_PROC (tsc_deadline_timer, TSC_DEADLINE); fails += CHECK_PROC (tsxldtrk, TSXLDTRK); fails += CHECK_PROC (umip, UMIP); fails += CHECK_PROC (vaes, VAES); |