diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2012-06-22 14:47:15 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-06-25 12:02:13 -0400 |
commit | 55f6cb9d0b364e7e8cb65b51193f5e4743c44fde (patch) | |
tree | 3c1051b460760d344e5787a6fce1aaac87d20415 /arch | |
parent | 4ad33411308596f2f918603509729922a1ec4411 (diff) |
x86, cpufeature: Catch duplicate CPU feature strings
We had a case of duplicate CPU feature strings, a user space ABI
violation, for almost two years. Make it a build error so that
doesn't happen again.
Link: http://lkml.kernel.org/r/4FE34BCB.5050305@linux.intel.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/cpu/mkcapflags.pl | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpu/mkcapflags.pl b/arch/x86/kernel/cpu/mkcapflags.pl index dfea390e1608..0c5b54919c7b 100644 --- a/arch/x86/kernel/cpu/mkcapflags.pl +++ b/arch/x86/kernel/cpu/mkcapflags.pl | |||
@@ -11,22 +11,35 @@ open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n"; | |||
11 | print OUT "#include <asm/cpufeature.h>\n\n"; | 11 | print OUT "#include <asm/cpufeature.h>\n\n"; |
12 | print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n"; | 12 | print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n"; |
13 | 13 | ||
14 | %features = (); | ||
15 | $err = 0; | ||
16 | |||
14 | while (defined($line = <IN>)) { | 17 | while (defined($line = <IN>)) { |
15 | if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) { | 18 | if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) { |
16 | $macro = $1; | 19 | $macro = $1; |
17 | $feature = $2; | 20 | $feature = "\L$2"; |
18 | $tail = $3; | 21 | $tail = $3; |
19 | if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) { | 22 | if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) { |
20 | $feature = $1; | 23 | $feature = "\L$1"; |
21 | } | 24 | } |
22 | 25 | ||
23 | if ($feature ne '') { | 26 | next if ($feature eq ''); |
24 | printf OUT "\t%-32s = \"%s\",\n", | 27 | |
25 | "[$macro]", "\L$feature"; | 28 | if ($features{$feature}++) { |
29 | print STDERR "$in: duplicate feature name: $feature\n"; | ||
30 | $err++; | ||
26 | } | 31 | } |
32 | printf OUT "\t%-32s = \"%s\",%s\n", "[$macro]", $feature; | ||
27 | } | 33 | } |
28 | } | 34 | } |
29 | print OUT "};\n"; | 35 | print OUT "};\n"; |
30 | 36 | ||
31 | close(IN); | 37 | close(IN); |
32 | close(OUT); | 38 | close(OUT); |
39 | |||
40 | if ($err) { | ||
41 | unlink($out); | ||
42 | exit(1); | ||
43 | } | ||
44 | |||
45 | exit(0); | ||