Skip to contentSkip to conversation

Cleanup and updates of x86 CPU definitions

PATCH H. Peter Anvin 2 participants 3 messages Aug 28, 2008 x86

lore
Share & tools
lore

H. Peter Anvin

author reviewer
#0 lore raw

Hi all,

I have just committed to tip:x86/cpu the following patch series:

H. Peter Anvin (3):
x86: generate names for /proc/cpuinfo from <asm/cpufeature.h>
x86: cpufeature: add Intel features from CPUID and AVX specs
x86: <asm/cpufeature.h>: clean up overlong lines, whitespace

The combined patch is below.

This changes the CPU feature naming code so that all that information comes from <asm-x86/cpufeature.h>. In the past we have had a number of problems with cpufeature.h diverging from what /proc/cpuinfo showed (not to mention that at one point we would show different things for 32 and 64 bits.)

I'm flagging this especially, since this is a patch fairly likely to conflict with other changes (incluing in other trees), although hopefully in a trivial fashion (this patchset should supercede) since I have gone through all the Intel and AMD documentation I could find and made sure it has the flags.

It is definitely unfortunate how the kernel sources and /proc/cpuinfo use different names for features; given that we can't change /proc/cpuinfo it might be worthwhile to run a sed script over the kernel sources.

-hpa

 arch/x86/boot/mkcpustr.c            |    2 +-
 arch/x86/kernel/cpu/Makefile        |   11 +++-
 arch/x86/kernel/cpu/feature_names.c |   84 ---------------------------
 arch/x86/kernel/cpu/mkcapflags.pl   |   32 ++++++++++
 arch/x86/kernel/cpu/powerflags.c    |   20 +++++++
 include/asm-x86/cpufeature.h        |  107 +++++++++++++++++++++++------------
 6 files changed, 134 insertions(+), 122 deletions(-)
arch/x86/boot/mkcpustr.c +1 -1
index bbe7695..4589caa 100644
@@ -15,7 +15,7 @@
 
 #include <stdio.h>
 
-#include "../kernel/cpu/feature_names.c"
+#include "../kernel/cpu/capflags.c"
 
 #if NCAPFLAGS > 8
 # error "Need to adjust the boot code handling of CPUID strings"
arch/x86/kernel/cpu/Makefile +10 -1
index a0fc6c1..3ede19a 100644
@@ -3,7 +3,7 @@
 #
 
 obj-y			:= intel_cacheinfo.o addon_cpuid_features.o
-obj-y			+= proc.o feature_names.o
+obj-y			+= proc.o capflags.o powerflags.o
 
 obj-$(CONFIG_X86_32)	+= common.o bugs.o cmpxchg.o
 obj-$(CONFIG_X86_64)	+= common_64.o bugs_64.o
@@ -23,3 +23,12 @@ obj-$(CONFIG_MTRR)	+= mtrr/
 obj-$(CONFIG_CPU_FREQ)	+= cpufreq/
 
 obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
+
+quiet_cmd_mkcapflags = MKCAP   $@
+      cmd_mkcapflags = $(PERL) $(srctree)/$(src)/mkcapflags.pl $< $@
+
+cpufeature = $(src)/../../../../include/asm-x86/cpufeature.h
+
+targets += capflags.c
+$(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.pl FORCE
+	$(call if_changed,mkcapflags)
arch/x86/kernel/cpu/feature_names.c deleted +0 -84

84 lines not on this page · raw message

arch/x86/kernel/cpu/mkcapflags.pl new file +32 -0
new file mode 100644
index 0000000..dfea390
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+#
+# Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h
+#
+
+($in, $out) = @ARGV;
+
+open(IN, "< $in\0")   or die "$0: cannot open: $in: $!\n";
+open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
+
+print OUT "#include <asm/cpufeature.h>\n\n";
+print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
+
+while (defined($line = <IN>)) {
+	if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
+		$macro = $1;
+		$feature = $2;
+		$tail = $3;
+		if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
+			$feature = $1;
+		}
+
+		if ($feature ne '') {
+			printf OUT "\t%-32s = \"%s\",\n",
+				"[$macro]", "\L$feature";
+		}
+	}
+}
+print OUT "};\n";
+
+close(IN);
+close(OUT);
arch/x86/kernel/cpu/powerflags.c new file +20 -0
new file mode 100644
index 0000000..5abbea2
@@ -0,0 +1,20 @@
+/*
+ * Strings for the various x86 power flags
+ *
+ * This file must not contain any executable code.
+ */
+
+#include <asm/cpufeature.h>
+
+const char *const x86_power_flags[32] = {
+	"ts",	/* temperature sensor */
+	"fid",  /* frequency id control */
+	"vid",  /* voltage id control */
+	"ttp",  /* thermal trip */
+	"tm",
+	"stc",
+	"100mhzsteps",
+	"hwpstate",
+	"",	/* tsc invariant mapped to constant_tsc */
+		/* nothing */
+};
include/asm-x86/cpufeature.h +71 -36

179 lines not on this page · raw message

#1 lore raw

include/asm-x86/cpufeature.h line 100

Quoted 3 lines · H. Peter Anvin
include/asm-x86/cpufeature.h +2 -0
+#define X86_FEATURE_VMX		(4*32+ 5) /* Hardware virtualization */
+#define X86_FEATURE_SMX		(4*32+ 6) /* "Safer" mode */

Is this supposed to appear as "Safer" in /proc/cpuinfo? Or should this be ``Safer''?

J

author reviewer
#2 lore raw
Quoted 6 lines · Jeremy Fitzhardinge

include/asm-x86/cpufeature.h line 100

Quoted 3 lines · H. Peter Anvin
include/asm-x86/cpufeature.h +2 -0
+#define X86_FEATURE_VMX		(4*32+ 5) /* Hardware virtualization */
+#define X86_FEATURE_SMX		(4*32+ 6) /* "Safer" mode */

Is this supposed to appear as "Safer" in /proc/cpuinfo? Or should this be ``Safer''?

It was a dumb-ass thinko on my part (already fixed in tip:x86/cpu).

-hpa