]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Introduce _dl_x86_init_cpu_failure for startup failure reporting
authorFlorian Weimer <fweimer@redhat.com>
Tue, 28 May 2024 07:04:24 +0000 (09:04 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 28 May 2024 07:12:57 +0000 (09:12 +0200)
sysdeps/x86/dl-get-cpu-features.c

index 579d02d63821465fb0fd2345c6f9fd6939b92995..f36d42d6afc3e45ab9a334865be154e10624ad4f 100644 (file)
@@ -32,6 +32,17 @@ extern void __x86_cpu_features (void) attribute_hidden;
 void (*const __x86_cpu_features_p) (void) attribute_hidden
   = __x86_cpu_features;
 
+_Noreturn static void __attribute__ ((unused))
+_dl_x86_init_cpu_failure (const struct cpu_features *cpu_features, int level)
+{
+  if (level == 5)
+    _dl_fatal_printf ("\
+Fatal glibc error: CPU does not support APX\n");
+  else
+    _dl_fatal_printf ("\
+Fatal glibc error: CPU does not support x86-64-v%d\n", level);
+}
+
 void
 _dl_x86_init_cpu_features (void)
 {
@@ -47,27 +58,23 @@ _dl_x86_init_cpu_features (void)
   && defined GCCMACRO__SSE3__ && defined GCCMACRO__SSSE3__             \
   && defined GCCMACRO__SSE4_1__ && defined GCCMACRO__SSE4_2__
       if (!(cpu_features->isa_1 & GNU_PROPERTY_X86_ISA_1_V2))
-       _dl_fatal_printf ("\
-Fatal glibc error: CPU does not support x86-64-v%d\n", 2);
+       _dl_x86_init_cpu_failure (cpu_features, 2);
 #   if defined GCCMACRO__AVX__ && defined GCCMACRO__AVX2__ \
   && defined GCCMACRO__F16C__ && defined GCCMACRO__FMA__   \
   && defined GCCMACRO__LZCNT__ && defined HAVE_X86_MOVBE
       if (!(cpu_features->isa_1 & GNU_PROPERTY_X86_ISA_1_V3))
-       _dl_fatal_printf ("\
-Fatal glibc error: CPU does not support x86-64-v%d\n", 3);
+       _dl_x86_init_cpu_failure (cpu_features, 3);
 #    if defined GCCMACRO__AVX512F__ && defined GCCMACRO__AVX512BW__ \
      && defined GCCMACRO__AVX512CD__ && defined GCCMACRO__AVX512DQ__ \
      && defined GCCMACRO__AVX512VL__
       if (!(cpu_features->isa_1 & GNU_PROPERTY_X86_ISA_1_V4))
-       _dl_fatal_printf ("\
-Fatal glibc error: CPU does not support x86-64-v%d\n", 4);
+       _dl_x86_init_cpu_failure (cpu_features, 4);
 #    endif /* ISA level 4 */
 #   endif /* ISA level 3 */
 #  endif /* ISA level 2 */
 # ifdef GCCMACRO__APX_F__
       if (!CPU_FEATURE_USABLE_P (cpu_features, APX_F))
-       _dl_fatal_printf ("\
-Fatal glibc error: CPU does not support APX\n");
+       _dl_x86_init_cpu_failure (cpu_features, 5);
 # endif
 # endif /* IS_IN (rtld) */
     }