aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2013-10-30 11:09:45 -0400
committerJosh Triplett <josh@joshtriplett.org>2014-08-17 18:54:00 -0400
commit9def39be4e960917fcb80514ff23651f9ec97193 (patch)
treefc898efcdaf87f15e70576481111291a4b8ed3ef /arch/x86/boot
parent39f838e06f46576694d425ac30fe8ff1e214fc0b (diff)
x86: Support compiling out human-friendly processor feature names
The table mapping CPUID bits to human-readable strings takes up a non-trivial amount of space, and only exists to support /proc/cpuinfo and a couple of kernel messages. Since programs depend on the format of /proc/cpuinfo, force inclusion of the table when building with /proc support; otherwise, support omitting that table to save space, in which case the kernel messages will print features numerically instead. In addition to saving 1408 bytes out of vmlinux, this also saves 1373 bytes out of the uncompressed setup code, which contributes directly to the size of bzImage. Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r--arch/x86/boot/Makefile7
-rw-r--r--arch/x86/boot/cpu.c68
2 files changed, 46 insertions, 29 deletions
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index dbe8dd2fe247..5b016e2498f3 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -35,19 +35,22 @@ setup-y += video-vesa.o
35setup-y += video-bios.o 35setup-y += video-bios.o
36 36
37targets += $(setup-y) 37targets += $(setup-y)
38hostprogs-y := mkcpustr tools/build 38hostprogs-y := tools/build
39hostprogs-$(CONFIG_X86_FEATURE_NAMES) += mkcpustr
39 40
40HOST_EXTRACFLAGS += -I$(srctree)/tools/include \ 41HOST_EXTRACFLAGS += -I$(srctree)/tools/include \
41 -include include/generated/autoconf.h \ 42 -include include/generated/autoconf.h \
42 -D__EXPORTED_HEADERS__ 43 -D__EXPORTED_HEADERS__
43 44
45ifdef CONFIG_X86_FEATURE_NAMES
44$(obj)/cpu.o: $(obj)/cpustr.h 46$(obj)/cpu.o: $(obj)/cpustr.h
45 47
46quiet_cmd_cpustr = CPUSTR $@ 48quiet_cmd_cpustr = CPUSTR $@
47 cmd_cpustr = $(obj)/mkcpustr > $@ 49 cmd_cpustr = $(obj)/mkcpustr > $@
48targets += cpustr.h 50targets += cpustr.h
49$(obj)/cpustr.h: $(obj)/mkcpustr FORCE 51$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
50 $(call if_changed,cpustr) 52 $(call if_changed,cpustr)
53endif
51 54
52# --------------------------------------------------------------------------- 55# ---------------------------------------------------------------------------
53 56
diff --git a/arch/x86/boot/cpu.c b/arch/x86/boot/cpu.c
index 6ec6bb6e9957..29207f69ae8c 100644
--- a/arch/x86/boot/cpu.c
+++ b/arch/x86/boot/cpu.c
@@ -16,7 +16,9 @@
16 */ 16 */
17 17
18#include "boot.h" 18#include "boot.h"
19#ifdef CONFIG_X86_FEATURE_NAMES
19#include "cpustr.h" 20#include "cpustr.h"
21#endif
20 22
21static char *cpu_name(int level) 23static char *cpu_name(int level)
22{ 24{
@@ -32,11 +34,48 @@ static char *cpu_name(int level)
32 } 34 }
33} 35}
34 36
37static void show_cap_strs(u32 *err_flags)
38{
39 int i, j;
40#ifdef CONFIG_X86_FEATURE_NAMES
41 const unsigned char *msg_strs = (const unsigned char *)x86_cap_strs;
42 for (i = 0; i < NCAPINTS; i++) {
43 u32 e = err_flags[i];
44 for (j = 0; j < 32; j++) {
45 if (msg_strs[0] < i ||
46 (msg_strs[0] == i && msg_strs[1] < j)) {
47 /* Skip to the next string */
48 msg_strs += 2;
49 while (*msg_strs++)
50 ;
51 }
52 if (e & 1) {
53 if (msg_strs[0] == i &&
54 msg_strs[1] == j &&
55 msg_strs[2])
56 printf("%s ", msg_strs+2);
57 else
58 printf("%d:%d ", i, j);
59 }
60 e >>= 1;
61 }
62 }
63#else
64 for (i = 0; i < NCAPINTS; i++) {
65 u32 e = err_flags[i];
66 for (j = 0; j < 32; j++) {
67 if (e & 1)
68 printf("%d:%d ", i, j);
69 e >>= 1;
70 }
71 }
72#endif
73}
74
35int validate_cpu(void) 75int validate_cpu(void)
36{ 76{
37 u32 *err_flags; 77 u32 *err_flags;
38 int cpu_level, req_level; 78 int cpu_level, req_level;
39 const unsigned char *msg_strs;
40 79
41 check_cpu(&cpu_level, &req_level, &err_flags); 80 check_cpu(&cpu_level, &req_level, &err_flags);
42 81
@@ -49,34 +88,9 @@ int validate_cpu(void)
49 } 88 }
50 89
51 if (err_flags) { 90 if (err_flags) {
52 int i, j;
53 puts("This kernel requires the following features " 91 puts("This kernel requires the following features "
54 "not present on the CPU:\n"); 92 "not present on the CPU:\n");
55 93 show_cap_strs(err_flags);
56 msg_strs = (const unsigned char *)x86_cap_strs;
57
58 for (i = 0; i < NCAPINTS; i++) {
59 u32 e = err_flags[i];
60
61 for (j = 0; j < 32; j++) {
62 if (msg_strs[0] < i ||
63 (msg_strs[0] == i && msg_strs[1] < j)) {
64 /* Skip to the next string */
65 msg_strs += 2;
66 while (*msg_strs++)
67 ;
68 }
69 if (e & 1) {
70 if (msg_strs[0] == i &&
71 msg_strs[1] == j &&
72 msg_strs[2])
73 printf("%s ", msg_strs+2);
74 else
75 printf("%d:%d ", i, j);
76 }
77 e >>= 1;
78 }
79 }
80 putchar('\n'); 94 putchar('\n');
81 return -1; 95 return -1;
82 } else { 96 } else {