x86 setup: print missing CPU features in cleartext
authorH. Peter Anvin <hpa@zytor.com>
Mon, 4 Feb 2008 15:48:00 +0000 (16:48 +0100)
committerIngo Molnar <mingo@elte.hu>
Mon, 4 Feb 2008 15:48:00 +0000 (16:48 +0100)
Instead of obscure numbers, print the list of missing CPU features in
cleartext.  To conserve space, use a host program (mkcpustr.c) to
produce a compact list of mandatory features only.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/boot/Makefile
arch/x86/boot/cpu.c
arch/x86/boot/mkcpustr.c [new file with mode: 0644]

index 254a58398a67bf0c8228841580a6d82eed2048ff..f88458e83ef0dabc17229685c3b6089d24b5a660 100644 (file)
@@ -26,7 +26,7 @@ SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
 #RAMDISK := -DRAMDISK=512
 
 targets                := vmlinux.bin setup.bin setup.elf zImage bzImage
-subdir-        := compressed
+subdir-                := compressed
 
 setup-y                += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
 setup-y                += header.o main.o mca.o memory.o pm.o pmjump.o
@@ -43,9 +43,17 @@ setup-y              += video-vesa.o
 setup-y                += video-bios.o
 
 targets                += $(setup-y)
-hostprogs-y    := tools/build
+hostprogs-y    := mkcpustr tools/build
 
-HOSTCFLAGS_build.o := $(LINUXINCLUDE)
+HOST_EXTRACFLAGS += $(LINUXINCLUDE)
+
+$(obj)/cpu.o: $(obj)/cpustr.h
+
+quiet_cmd_cpustr = CPUSTR  $@
+      cmd_cpustr = $(obj)/mkcpustr > $@
+targets                += cpustr.h
+$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
+       $(call if_changed,cpustr)
 
 # ---------------------------------------------------------------------------
 
@@ -98,7 +106,7 @@ $(obj)/compressed/vmlinux: FORCE
        $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
 
 # Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
-FDARGS = 
+FDARGS =
 # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
 FDINITRD =
 
index 2a5c32da5852a307424a1b5105e60cff63e2d7ce..00e19edd852c60d8cc32a2b009a604938747dd77 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- linux-c -*- ------------------------------------------------------- *
  *
  *   Copyright (C) 1991, 1992 Linus Torvalds
- *   Copyright 2007 rPath, Inc. - All Rights Reserved
+ *   Copyright 2007-2008 rPath, Inc. - All Rights Reserved
  *
  *   This file is part of the Linux kernel, and is made available under
  *   the terms of the GNU General Public License version 2.
@@ -9,7 +9,7 @@
  * ----------------------------------------------------------------------- */
 
 /*
- * arch/i386/boot/cpu.c
+ * arch/x86/boot/cpu.c
  *
  * Check for obligatory CPU features and abort if the features are not
  * present.
@@ -19,6 +19,8 @@
 #include "bitops.h"
 #include <asm/cpufeature.h>
 
+#include "cpustr.h"
+
 static char *cpu_name(int level)
 {
        static char buf[6];
@@ -35,6 +37,7 @@ int validate_cpu(void)
 {
        u32 *err_flags;
        int cpu_level, req_level;
+       const unsigned char *msg_strs;
 
        check_cpu(&cpu_level, &req_level, &err_flags);
 
@@ -51,13 +54,26 @@ int validate_cpu(void)
                puts("This kernel requires the following features "
                     "not present on the CPU:\n");
 
+               msg_strs = (const unsigned char *)x86_cap_strs;
+
                for (i = 0; i < NCAPINTS; i++) {
                        u32 e = err_flags[i];
 
                        for (j = 0; j < 32; j++) {
-                               if (e & 1)
-                                       printf("%d:%d ", i, j);
-
+                               int n = (i << 5)+j;
+                               if (*msg_strs < n) {
+                                       /* Skip to the next string */
+                                       do {
+                                               msg_strs++;
+                                       } while (*msg_strs);
+                                       msg_strs++;
+                               }
+                               if (e & 1) {
+                                       if (*msg_strs == n && msg_strs[1])
+                                               printf("%s ", msg_strs+1);
+                                       else
+                                               printf("%d:%d ", i, j);
+                               }
                                e >>= 1;
                        }
                }
diff --git a/arch/x86/boot/mkcpustr.c b/arch/x86/boot/mkcpustr.c
new file mode 100644 (file)
index 0000000..bbe7695
--- /dev/null
@@ -0,0 +1,49 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2008 rPath, Inc. - All Rights Reserved
+ *
+ *   This file is part of the Linux kernel, and is made available under
+ *   the terms of the GNU General Public License version 2 or (at your
+ *   option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * This is a host program to preprocess the CPU strings into a
+ * compact format suitable for the setup code.
+ */
+
+#include <stdio.h>
+
+#include "../kernel/cpu/feature_names.c"
+
+#if NCAPFLAGS > 8
+# error "Need to adjust the boot code handling of CPUID strings"
+#endif
+
+int main(void)
+{
+       int i;
+       const char *str;
+
+       printf("static const char x86_cap_strs[] = \n");
+
+       for (i = 0; i < NCAPINTS*32; i++) {
+               str = x86_cap_flags[i];
+
+               if (i == NCAPINTS*32-1) {
+                       /* The last entry must be unconditional; this
+                          also consumes the compiler-added null character */
+                       if (!str)
+                               str = "";
+                       printf("\t\"\\x%02x\"\"%s\"\n", i, str);
+               } else if (str) {
+                       printf("#if REQUIRED_MASK%d & (1 << %d)\n"
+                              "\t\"\\x%02x\"\"%s\\0\"\n"
+                              "#endif\n",
+                              i >> 5, i & 31, i, str);
+               }
+       }
+       printf("\t;\n");
+       return 0;
+}