2 #include <linux/timex.h>
3 #include <linux/string.h>
4 #include <asm/semaphore.h>
5 #include <linux/seq_file.h>
8 * Get CPU information for use by the procfs.
10 static int show_cpuinfo(struct seq_file *m, void *v)
13 * These flag bits must match the definitions in <asm/cpufeature.h>.
14 * NULL means this bit is undefined or reserved; either way it doesn't
15 * have meaning as far as Linux is concerned. Note that it's important
16 * to realize there is a difference between this table and CPUID -- if
17 * applications want to get the raw CPUID data, they should access
18 * /dev/cpu/<cpu_nr>/cpuid instead.
20 static char *x86_cap_flags[] = {
22 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
23 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
24 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
25 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
28 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
29 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
30 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
31 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
33 /* Transmeta-defined */
34 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
35 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
36 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
37 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
39 /* Other (Linux-defined) */
40 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
41 NULL, NULL, NULL, NULL,
42 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
43 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
44 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
46 /* Intel-defined (#2) */
47 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", NULL, "est",
48 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
49 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
50 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
52 /* VIA/Cyrix/Centaur-defined */
53 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
54 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
55 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
56 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
58 /* AMD-defined (#2) */
59 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL,
60 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
61 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
62 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
64 struct cpuinfo_x86 *c = v;
65 int i, n = c - cpu_data;
72 seq_printf(m, "processor\t: %d\n"
78 c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
81 c->x86_model_id[0] ? c->x86_model_id : "unknown");
83 if (c->x86_mask || c->cpuid_level >= 0)
84 seq_printf(m, "stepping\t: %d\n", c->x86_mask);
86 seq_printf(m, "stepping\t: unknown\n");
88 if ( cpu_has(c, X86_FEATURE_TSC) ) {
89 seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
90 cpu_khz / 1000, (cpu_khz % 1000));
94 if (c->x86_cache_size >= 0)
95 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
97 if (c->x86_max_cores * smp_num_siblings > 1) {
98 seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
99 seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
100 seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]);
101 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
105 /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
106 fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
107 seq_printf(m, "fdiv_bug\t: %s\n"
112 "fpu_exception\t: %s\n"
113 "cpuid level\t: %d\n"
116 c->fdiv_bug ? "yes" : "no",
117 c->hlt_works_ok ? "no" : "yes",
118 c->f00f_bug ? "yes" : "no",
119 c->coma_bug ? "yes" : "no",
120 c->hard_math ? "yes" : "no",
121 fpu_exception ? "yes" : "no",
123 c->wp_works_ok ? "yes" : "no");
125 for ( i = 0 ; i < 32*NCAPINTS ; i++ )
126 if ( test_bit(i, c->x86_capability) &&
127 x86_cap_flags[i] != NULL )
128 seq_printf(m, " %s", x86_cap_flags[i]);
130 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
131 c->loops_per_jiffy/(500000/HZ),
132 (c->loops_per_jiffy/(5000/HZ)) % 100);
137 static void *c_start(struct seq_file *m, loff_t *pos)
139 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
141 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
144 return c_start(m, pos);
146 static void c_stop(struct seq_file *m, void *v)
149 struct seq_operations cpuinfo_op = {
153 .show = show_cpuinfo,