blob: e79380aef43b5e1b2fb8aa032ee858d28affe81b [file] [log] [blame]
Stefan Reinauer23190272008-08-20 13:41:24 +00001/*
2 * inteltool - dump all registers on an Intel CPU + chipset based system.
3 *
Stefan Reinauer14e22772010-04-27 06:56:47 +00004 * Copyright (C) 2008-2010 by coresystems GmbH
5 *
Stefan Reinauer23190272008-08-20 13:41:24 +00006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#include <fcntl.h>
21#include <unistd.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#include <errno.h>
26
27#include "inteltool.h"
28
29int fd_msr;
30
31unsigned int cpuid(unsigned int op)
32{
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000033 uint32_t ret;
34
35#if defined(__DARWIN__) && !defined(__LP64__)
Stefan Reinauer1c60c882010-05-30 12:35:39 +000036 asm volatile (
37 "pushl %%ebx\n"
38 "cpuid\n"
39 "popl %%ebx\n"
40 : "=a" (ret) : "a" (op) : "%ecx", "%edx"
41 );
Stefan Reinauerf1824562009-04-22 23:17:44 +000042#else
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000043 asm ("cpuid" : "=a" (ret) : "a" (op) : "%ebx", "%ecx", "%edx");
Stefan Reinauerf1824562009-04-22 23:17:44 +000044#endif
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000045
Stefan Reinauer23190272008-08-20 13:41:24 +000046 return ret;
47}
48
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000049#ifndef __DARWIN__
Stefan Reinauer23190272008-08-20 13:41:24 +000050int msr_readerror = 0;
51
52msr_t rdmsr(int addr)
53{
54 uint8_t buf[8];
55 msr_t msr = { 0xffffffff, 0xffffffff };
56
57 if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
58 perror("Could not lseek() to MSR");
59 close(fd_msr);
60 exit(1);
61 }
62
63 if (read(fd_msr, buf, 8) == 8) {
64 msr.lo = *(uint32_t *)buf;
65 msr.hi = *(uint32_t *)(buf + 4);
66
67 return msr;
68 }
69
70 if (errno == 5) {
71 printf(" (*)"); // Not all bits of the MSR could be read
72 msr_readerror = 1;
73 } else {
74 // A severe error.
75 perror("Could not read() MSR");
76 close(fd_msr);
77 exit(1);
78 }
79
80 return msr;
81}
Stefan Reinauer1162f252008-12-04 15:18:20 +000082#endif
Stefan Reinauer23190272008-08-20 13:41:24 +000083
84int print_intel_core_msrs(void)
85{
86 unsigned int i, core, id;
87 msr_t msr;
88
89#define IA32_PLATFORM_ID 0x0017
90#define EBL_CR_POWERON 0x002a
91#define FSB_CLK_STS 0x00cd
92#define IA32_TIME_STAMP_COUNTER 0x0010
93#define IA32_APIC_BASE 0x001b
94
95 typedef struct {
96 int number;
97 char *name;
98 } msr_entry_t;
99
Tobias Diedrich3645e612010-11-27 14:44:19 +0000100 /* Pentium III */
101 static const msr_entry_t model67x_global_msrs[] = {
102 { 0x0000, "IA32_P5_MC_ADDR" },
103 { 0x0001, "IA32_P5_MC_TYPE" },
104 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
105 { 0x0017, "IA32_PLATFORM_ID" },
106 { 0x001b, "IA32_APIC_BASE" },
107 { 0x002a, "EBL_CR_POWERON" },
108 { 0x0033, "TEST_CTL" },
109 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
110 { 0x0088, "BBL_CR_D0" },
111 { 0x0089, "BBL_CR_D1" },
112 { 0x008a, "BBL_CR_D2" },
113 { 0x008b, "IA32_BIOS_SIGN_ID" },
114 { 0x00c1, "PERFCTR0" },
115 { 0x00c2, "PERFCTR1" },
116 { 0x00fe, "IA32_MTRRCAP" },
117 { 0x0116, "BBL_CR_ADDR" },
118 { 0x0118, "BBL_CR_DECC" },
119 { 0x0119, "BBL_CR_CTL" },
120 //{ 0x011a, "BBL_CR_TRIG" },
121 { 0x011b, "BBL_CR_BUSY" },
122 { 0x011e, "BBL_CR_CTL3" },
123 { 0x0174, "IA32_SYSENTER_CS" },
124 { 0x0175, "IA32_SYSENTER_ESP" },
125 { 0x0176, "IA32_SYSENTER_EIP" },
126 { 0x0179, "IA32_MCG_CAP" },
127 { 0x017a, "IA32_MCG_STATUS" },
128 { 0x017b, "IA32_MCG_CTL" },
129 { 0x0186, "IA32_PERF_EVNTSEL0" },
130 { 0x0187, "IA32_PERF_EVNTSEL1" },
131 { 0x01d9, "IA32_DEBUGCTL" },
132 { 0x01db, "MSR_LASTBRANCHFROMIP" },
133 { 0x01dc, "MSR_LASTBRANCHTOIP" },
134 { 0x01dd, "MSR_LASTINTFROMIP" },
135 { 0x01de, "MSR_LASTINTTOIP" },
136 { 0x01e0, "MSR_ROB_CR_BKUPTMPDR6" },
137 { 0x0200, "IA32_MTRR_PHYSBASE0" },
138 { 0x0201, "IA32_MTRR_PHYSMASK0" },
139 { 0x0202, "IA32_MTRR_PHYSBASE1" },
140 { 0x0203, "IA32_MTRR_PHYSMASK1" },
141 { 0x0204, "IA32_MTRR_PHYSBASE2" },
142 { 0x0205, "IA32_MTRR_PHYSMASK2" },
143 { 0x0206, "IA32_MTRR_PHYSBASE3" },
144 { 0x0207, "IA32_MTRR_PHYSMASK3" },
145 { 0x0208, "IA32_MTRR_PHYSBASE4" },
146 { 0x0209, "IA32_MTRR_PHYSMASK4" },
147 { 0x020a, "IA32_MTRR_PHYSBASE5" },
148 { 0x020b, "IA32_MTRR_PHYSMASK5" },
149 { 0x020c, "IA32_MTRR_PHYSBASE6" },
150 { 0x020d, "IA32_MTRR_PHYSMASK6" },
151 { 0x020e, "IA32_MTRR_PHYSBASE7" },
152 { 0x020f, "IA32_MTRR_PHYSMASK7" },
153 { 0x0250, "IA32_MTRR_FIX64K_00000" },
154 { 0x0258, "IA32_MTRR_FIX16K_80000" },
155 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
156 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
157 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
158 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
159 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
160 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
161 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
162 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
163 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
164 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
165 { 0x0400, "IA32_MC0_CTL" },
166 { 0x0401, "IA32_MC0_STATUS" },
167 { 0x0402, "IA32_MC0_ADDR" },
168 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
169 { 0x0404, "IA32_MC1_CTL" },
170 { 0x0405, "IA32_MC1_STATUS" },
171 { 0x0406, "IA32_MC1_ADDR" },
172 //{ 0x0407, "IA32_MC1_MISC" }, // Seems to be RO
173 { 0x0408, "IA32_MC2_CTL" },
174 { 0x0409, "IA32_MC2_STATUS" },
175 { 0x040a, "IA32_MC2_ADDR" },
176 //{ 0x040b, "IA32_MC2_MISC" }, // Seems to be RO
177 { 0x040c, "IA32_MC4_CTL" },
178 { 0x040d, "IA32_MC4_STATUS" },
179 { 0x040e, "IA32_MC4_ADDR" },
180 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
181 { 0x0410, "IA32_MC3_CTL" },
182 { 0x0411, "IA32_MC3_STATUS" },
183 { 0x0412, "IA32_MC3_ADDR" },
184 //{ 0x0413, "IA32_MC3_MISC" }, // Seems to be RO
185 };
186
Stefan Reinauer04844812010-02-22 11:26:06 +0000187 static const msr_entry_t model6bx_global_msrs[] = {
188 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
189 { 0x0017, "IA32_PLATFORM_ID" },
190 { 0x001b, "IA32_APIC_BASE" },
191 { 0x002a, "EBL_CR_POWERON" },
192 { 0x0033, "TEST_CTL" },
193 { 0x003f, "THERM_DIODE_OFFSET" },
Stefan Reinauer14e22772010-04-27 06:56:47 +0000194 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
Stefan Reinauer04844812010-02-22 11:26:06 +0000195 { 0x008b, "IA32_BIOS_SIGN_ID" },
196 { 0x00c1, "PERFCTR0" },
197 { 0x00c2, "PERFCTR1" },
198 { 0x011e, "BBL_CR_CTL3" },
199 { 0x0179, "IA32_MCG_CAP" },
200 { 0x017a, "IA32_MCG_STATUS" },
201 { 0x0198, "IA32_PERF_STATUS" },
202 { 0x0199, "IA32_PERF_CONTROL" },
203 { 0x019a, "IA32_CLOCK_MODULATION" },
204 { 0x01a0, "IA32_MISC_ENABLES" },
205 { 0x01d9, "IA32_DEBUGCTL" },
206 { 0x0200, "IA32_MTRR_PHYSBASE0" },
207 { 0x0201, "IA32_MTRR_PHYSMASK0" },
208 { 0x0202, "IA32_MTRR_PHYSBASE1" },
209 { 0x0203, "IA32_MTRR_PHYSMASK1" },
210 { 0x0204, "IA32_MTRR_PHYSBASE2" },
211 { 0x0205, "IA32_MTRR_PHYSMASK2" },
212 { 0x0206, "IA32_MTRR_PHYSBASE3" },
213 { 0x0207, "IA32_MTRR_PHYSMASK3" },
214 { 0x0208, "IA32_MTRR_PHYSBASE4" },
215 { 0x0209, "IA32_MTRR_PHYSMASK4" },
216 { 0x020a, "IA32_MTRR_PHYSBASE5" },
217 { 0x020b, "IA32_MTRR_PHYSMASK5" },
218 { 0x020c, "IA32_MTRR_PHYSBASE6" },
219 { 0x020d, "IA32_MTRR_PHYSMASK6" },
220 { 0x020e, "IA32_MTRR_PHYSBASE7" },
221 { 0x020f, "IA32_MTRR_PHYSMASK7" },
222 { 0x0250, "IA32_MTRR_FIX64K_00000" },
223 { 0x0258, "IA32_MTRR_FIX16K_80000" },
224 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
225 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
226 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
227 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
228 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
229 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
230 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
231 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
232 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
233 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
234 { 0x0400, "IA32_MC0_CTL" },
235 { 0x0401, "IA32_MC0_STATUS" },
236 { 0x0402, "IA32_MC0_ADDR" },
237 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
238 { 0x040c, "IA32_MC4_CTL" },
239 { 0x040d, "IA32_MC4_STATUS" },
240 { 0x040e, "IA32_MC4_ADDR" },
241 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
242 };
243
Stefan Reinauer23190272008-08-20 13:41:24 +0000244 static const msr_entry_t model6ex_global_msrs[] = {
245 { 0x0017, "IA32_PLATFORM_ID" },
246 { 0x002a, "EBL_CR_POWERON" },
247 { 0x00cd, "FSB_CLOCK_STS" },
248 { 0x00ce, "FSB_CLOCK_VCC" },
249 { 0x00e2, "CLOCK_CST_CONFIG_CONTROL" },
250 { 0x00e3, "PMG_IO_BASE_ADDR" },
251 { 0x00e4, "PMG_IO_CAPTURE_ADDR" },
252 { 0x00ee, "EXT_CONFIG" },
253 { 0x011e, "BBL_CR_CTL3" },
254 { 0x0194, "CLOCK_FLEX_MAX" },
255 { 0x0198, "IA32_PERF_STATUS" },
256 { 0x01a0, "IA32_MISC_ENABLES" },
257 { 0x01aa, "PIC_SENS_CFG" },
258 { 0x0400, "IA32_MC0_CTL" },
259 { 0x0401, "IA32_MC0_STATUS" },
260 { 0x0402, "IA32_MC0_ADDR" },
261 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
262 { 0x040c, "IA32_MC4_CTL" },
263 { 0x040d, "IA32_MC4_STATUS" },
264 { 0x040e, "IA32_MC4_ADDR" },
265 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
266 };
267
268 static const msr_entry_t model6ex_per_core_msrs[] = {
269 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
270 { 0x001b, "IA32_APIC_BASE" },
271 { 0x003a, "IA32_FEATURE_CONTROL" },
272 { 0x003f, "IA32_TEMPERATURE_OFFSET" },
273 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
274 { 0x008b, "IA32_BIOS_SIGN_ID" },
275 { 0x00e7, "IA32_MPERF" },
276 { 0x00e8, "IA32_APERF" },
277 { 0x00fe, "IA32_MTRRCAP" },
278 { 0x015f, "DTS_CAL_CTRL" },
279 { 0x0179, "IA32_MCG_CAP" },
280 { 0x017a, "IA32_MCG_STATUS" },
281 { 0x0199, "IA32_PERF_CONTROL" },
282 { 0x019a, "IA32_CLOCK_MODULATION" },
283 { 0x019b, "IA32_THERM_INTERRUPT" },
284 { 0x019c, "IA32_THERM_STATUS" },
285 { 0x019d, "GV_THERM" },
286 { 0x01d9, "IA32_DEBUGCTL" },
287 { 0x0200, "IA32_MTRR_PHYSBASE0" },
288 { 0x0201, "IA32_MTRR_PHYSMASK0" },
289 { 0x0202, "IA32_MTRR_PHYSBASE1" },
290 { 0x0203, "IA32_MTRR_PHYSMASK1" },
291 { 0x0204, "IA32_MTRR_PHYSBASE2" },
292 { 0x0205, "IA32_MTRR_PHYSMASK2" },
293 { 0x0206, "IA32_MTRR_PHYSBASE3" },
294 { 0x0207, "IA32_MTRR_PHYSMASK3" },
295 { 0x0208, "IA32_MTRR_PHYSBASE4" },
296 { 0x0209, "IA32_MTRR_PHYSMASK4" },
297 { 0x020a, "IA32_MTRR_PHYSBASE5" },
298 { 0x020b, "IA32_MTRR_PHYSMASK5" },
299 { 0x020c, "IA32_MTRR_PHYSBASE6" },
300 { 0x020d, "IA32_MTRR_PHYSMASK6" },
301 { 0x020e, "IA32_MTRR_PHYSBASE7" },
302 { 0x020f, "IA32_MTRR_PHYSMASK7" },
303 { 0x0250, "IA32_MTRR_FIX64K_00000" },
304 { 0x0258, "IA32_MTRR_FIX16K_80000" },
305 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
306 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
307 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
308 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
309 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
310 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
311 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
312 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
313 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
314 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
315 //{ 0x00c000080, "IA32_CR_EFER" }, // Seems to be RO
316 };
317
318 static const msr_entry_t model6fx_global_msrs[] = {
319 { 0x0017, "IA32_PLATFORM_ID" },
320 { 0x002a, "EBL_CR_POWERON" },
321 { 0x003f, "IA32_TEMPERATURE_OFFSET" },
322 { 0x00a8, "EMTTM_CR_TABLE0" },
323 { 0x00a9, "EMTTM_CR_TABLE1" },
324 { 0x00aa, "EMTTM_CR_TABLE2" },
325 { 0x00ab, "EMTTM_CR_TABLE3" },
326 { 0x00ac, "EMTTM_CR_TABLE4" },
327 { 0x00ad, "EMTTM_CR_TABLE5" },
328 { 0x00cd, "FSB_CLOCK_STS" },
329 { 0x00e2, "PMG_CST_CONFIG_CONTROL" },
330 { 0x00e3, "PMG_IO_BASE_ADDR" },
331 { 0x00e4, "PMG_IO_CAPTURE_ADDR" },
332 { 0x00ee, "EXT_CONFIG" },
333 { 0x011e, "BBL_CR_CTL3" },
334 { 0x0194, "CLOCK_FLEX_MAX" },
335 { 0x0198, "IA32_PERF_STATUS" },
336 { 0x01a0, "IA32_MISC_ENABLES" },
337 { 0x01aa, "PIC_SENS_CFG" },
338 { 0x0400, "IA32_MC0_CTL" },
339 { 0x0401, "IA32_MC0_STATUS" },
340 { 0x0402, "IA32_MC0_ADDR" },
341 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
342 { 0x040c, "IA32_MC4_CTL" },
343 { 0x040d, "IA32_MC4_STATUS" },
344 { 0x040e, "IA32_MC4_ADDR" },
345 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
346 };
347
348 static const msr_entry_t model6fx_per_core_msrs[] = {
349 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
350 { 0x001b, "IA32_APIC_BASE" },
351 { 0x003a, "IA32_FEATURE_CONTROL" },
352 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
353 { 0x008b, "IA32_BIOS_SIGN_ID" },
354 { 0x00e1, "SMM_CST_MISC_INFO" },
355 { 0x00e7, "IA32_MPERF" },
356 { 0x00e8, "IA32_APERF" },
357 { 0x00fe, "IA32_MTRRCAP" },
358 { 0x0179, "IA32_MCG_CAP" },
359 { 0x017a, "IA32_MCG_STATUS" },
360 { 0x0199, "IA32_PERF_CONTROL" },
361 { 0x019a, "IA32_THERM_CTL" },
362 { 0x019b, "IA32_THERM_INTERRUPT" },
363 { 0x019c, "IA32_THERM_STATUS" },
364 { 0x019d, "MSR_THERM2_CTL" },
365 { 0x01d9, "IA32_DEBUGCTL" },
366 { 0x0200, "IA32_MTRR_PHYSBASE0" },
367 { 0x0201, "IA32_MTRR_PHYSMASK0" },
368 { 0x0202, "IA32_MTRR_PHYSBASE1" },
369 { 0x0203, "IA32_MTRR_PHYSMASK1" },
370 { 0x0204, "IA32_MTRR_PHYSBASE2" },
371 { 0x0205, "IA32_MTRR_PHYSMASK2" },
372 { 0x0206, "IA32_MTRR_PHYSBASE3" },
373 { 0x0207, "IA32_MTRR_PHYSMASK3" },
374 { 0x0208, "IA32_MTRR_PHYSBASE4" },
375 { 0x0209, "IA32_MTRR_PHYSMASK4" },
376 { 0x020a, "IA32_MTRR_PHYSBASE5" },
377 { 0x020b, "IA32_MTRR_PHYSMASK5" },
378 { 0x020c, "IA32_MTRR_PHYSBASE6" },
379 { 0x020d, "IA32_MTRR_PHYSMASK6" },
380 { 0x020e, "IA32_MTRR_PHYSBASE7" },
381 { 0x020f, "IA32_MTRR_PHYSMASK7" },
382 { 0x0250, "IA32_MTRR_FIX64K_00000" },
383 { 0x0258, "IA32_MTRR_FIX16K_80000" },
384 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
385 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
386 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
387 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
388 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
389 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
390 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
391 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
392 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
393 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
394 //{ 0x00c000080, "IA32_CR_EFER" }, // Seems to be RO
395 };
396
Pat Erleyca3548e2010-04-21 06:23:19 +0000397 /* Pentium 4 and XEON */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000398 /*
399 * All MSRs per
Pat Erleyca3548e2010-04-21 06:23:19 +0000400 *
Idwer Vollering312fc962010-12-17 22:34:58 +0000401 * Intel 64 and IA-32 Architectures Software Developer's Manual
402 * Volume 3B: System Programming Guide, Part 2
Pat Erleyca3548e2010-04-21 06:23:19 +0000403 *
Idwer Vollering312fc962010-12-17 22:34:58 +0000404 * Table B-5, B-7
Pat Erleyca3548e2010-04-21 06:23:19 +0000405 */
Idwer Vollering312fc962010-12-17 22:34:58 +0000406 static const msr_entry_t modelf2x_global_msrs[] = {
407 { 0x0000, "IA32_P5_MC_ADDR" },
408 { 0x0001, "IA32_P5_MC_TYPE" },
409 /* 0x6: Not available in model 2. */
410 { 0x0017, "IA32_PLATFORM_ID" },
411 { 0x002a, "MSR_EBC_HARD_POWERON" },
412 { 0x002b, "MSR_EBC_SOFT_POWRON" },
413 /* 0x2c: Not available in model 2. */
414// WRITE ONLY { 0x0079, "IA32_BIOS_UPDT_TRIG" },
415 { 0x019c, "IA32_THERM_STATUS" },
416 /* 0x19d: Not available in model 2. */
417 { 0x01a0, "IA32_MISC_ENABLE" },
418 /* 0x1a1: Not available in model 2. */
419 { 0x0200, "IA32_MTRR_PHYSBASE0" },
420 { 0x0201, "IA32_MTRR_PHYSMASK0" },
421 { 0x0202, "IA32_MTRR_PHYSBASE1" },
422 { 0x0203, "IA32_MTRR_PHYSMASK1" },
423 { 0x0204, "IA32_MTRR_PHYSBASE2" },
424 { 0x0205, "IA32_MTRR_PHYSMASK2" },
425 { 0x0206, "IA32_MTRR_PHYSBASE3" },
426 { 0x0207, "IA32_MTRR_PHYSMASK3" },
427 { 0x0208, "IA32_MTRR_PHYSBASE4" },
428 { 0x0209, "IA32_MTRR_PHYSMASK4" },
429 { 0x020a, "IA32_MTRR_PHYSBASE5" },
430 { 0x020b, "IA32_MTRR_PHYSMASK5" },
431 { 0x020c, "IA32_MTRR_PHYSBASE6" },
432 { 0x020d, "IA32_MTRR_PHYSMASK6" },
433 { 0x020e, "IA32_MTRR_PHYSBASE7" },
434 { 0x020f, "IA32_MTRR_PHYSMASK7" },
435 { 0x0250, "IA32_MTRR_FIX64K_00000" },
436 { 0x0258, "IA32_MTRR_FIX16K_80000" },
437 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
438 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
439 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
440 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
441 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
442 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
443 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
444 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
445 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
446 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
447 { 0x0300, "MSR_BPU_COUNTER0" },
448 { 0x0301, "MSR_BPU_COUNTER1" },
449 { 0x0302, "MSR_BPU_COUNTER2" },
450 { 0x0303, "MSR_BPU_COUNTER3" },
451 { 0x0304, "MSR_MS_COUNTER0" },
452 { 0x0305, "MSR_MS_COUNTER1" },
453 { 0x0306, "MSR_MS_COUNTER2" },
454 { 0x0307, "MSR_MS_COUNTER3" },
455 { 0x0308, "MSR_FLAME_COUNTER0" },
456 { 0x0309, "MSR_FLAME_COUNTER1" },
457 { 0x030a, "MSR_FLAME_COUNTER2" },
458 { 0x030b, "MSR_FLAME_COUNTER3" },
459 { 0x030c, "MSR_IQ_COUNTER0" },
460 { 0x030d, "MSR_IQ_COUNTER1" },
461 { 0x030e, "MSR_IQ_COUNTER2" },
462 { 0x030f, "MSR_IQ_COUNTER3" },
463 { 0x0310, "MSR_IQ_COUNTER4" },
464 { 0x0311, "MSR_IQ_COUNTER5" },
465 { 0x0360, "MSR_BPU_CCCR0" },
466 { 0x0361, "MSR_BPU_CCCR1" },
467 { 0x0362, "MSR_BPU_CCCR2" },
468 { 0x0363, "MSR_BPU_CCCR3" },
469 { 0x0364, "MSR_MS_CCCR0" },
470 { 0x0365, "MSR_MS_CCCR1" },
471 { 0x0366, "MSR_MS_CCCR2" },
472 { 0x0367, "MSR_MS_CCCR3" },
473 { 0x0368, "MSR_FLAME_CCCR0" },
474 { 0x0369, "MSR_FLAME_CCCR1" },
475 { 0x036a, "MSR_FLAME_CCCR2" },
476 { 0x036b, "MSR_FLAME_CCCR3" },
477 { 0x036c, "MSR_IQ_CCCR0" },
478 { 0x036d, "MSR_IQ_CCCR1" },
479 { 0x036e, "MSR_IQ_CCCR2" },
480 { 0x036f, "MSR_IQ_CCCR3" },
481 { 0x0370, "MSR_IQ_CCCR4" },
482 { 0x0371, "MSR_IQ_CCCR5" },
483 { 0x03a0, "MSR_BSU_ESCR0" },
484 { 0x03a1, "MSR_BSU_ESCR1" },
485 { 0x03a2, "MSR_FSB_ESCR0" },
486 { 0x03a3, "MSR_FSB_ESCR1" },
487 { 0x03a4, "MSR_FIRM_ESCR0" },
488 { 0x03a5, "MSR_FIRM_ESCR1" },
489 { 0x03a6, "MSR_FLAME_ESCR0" },
490 { 0x03a7, "MSR_FLAME_ESCR1" },
491 { 0x03a8, "MSR_DAC_ESCR0" },
492 { 0x03a9, "MSR_DAC_ESCR1" },
493 { 0x03aa, "MSR_MOB_ESCR0" },
494 { 0x03ab, "MSR_MOB_ESCR1" },
495 { 0x03ac, "MSR_PMH_ESCR0" },
496 { 0x03ad, "MSR_PMH_ESCR1" },
497 { 0x03ae, "MSR_SAAT_ESCR0" },
498 { 0x03af, "MSR_SAAT_ESCR1" },
499 { 0x03b0, "MSR_U2L_ESCR0" },
500 { 0x03b1, "MSR_U2L_ESCR1" },
501 { 0x03b2, "MSR_BPU_ESCR0" },
502 { 0x03b3, "MSR_BPU_ESCR1" },
503 { 0x03b4, "MSR_IS_ESCR0" },
504 { 0x03b5, "MSR_BPU_ESCR1" },
505 { 0x03b6, "MSR_ITLB_ESCR0" },
506 { 0x03b7, "MSR_ITLB_ESCR1" },
507 { 0x03b8, "MSR_CRU_ESCR0" },
508 { 0x03b9, "MSR_CRU_ESCR1" },
509 { 0x03ba, "MSR_IQ_ESCR0" },
510 { 0x03bb, "MSR_IQ_ESCR1" },
511 { 0x03bc, "MSR_RAT_ESCR0" },
512 { 0x03bd, "MSR_RAT_ESCR1" },
513 { 0x03be, "MSR_SSU_ESCR0" },
514 { 0x03c0, "MSR_MS_ESCR0" },
515 { 0x03c1, "MSR_MS_ESCR1" },
516 { 0x03c2, "MSR_TBPU_ESCR0" },
517 { 0x03c3, "MSR_TBPU_ESCR1" },
518 { 0x03c4, "MSR_TC_ESCR0" },
519 { 0x03c5, "MSR_TC_ESCR1" },
520 { 0x03c8, "MSR_IX_ESCR0" },
521 { 0x03c9, "MSR_IX_ESCR1" },
522 { 0x03ca, "MSR_ALF_ESCR0" },
523 { 0x03cb, "MSR_ALF_ESCR1" },
524 { 0x03cc, "MSR_CRU_ESCR2" },
525 { 0x03cd, "MSR_CRU_ESCR3" },
526 { 0x03e0, "MSR_CRU_ESCR4" },
527 { 0x03e1, "MSR_CRU_ESCR5" },
528 { 0x03f0, "MSR_TC_PRECISE_EVENT" },
529 { 0x03f1, "MSR_PEBS_ENABLE" },
530 { 0x03f2, "MSR_PEBS_MATRIX_VERT" },
531
532 /*
533 * All MCX_ADDR and MCX_MISC MSRs depend on a bit being
534 * set in MCX_STATUS.
535 */
536 { 0x400, "IA32_MC0_CTL" },
537 { 0x401, "IA32_MC0_STATUS" },
538 { 0x402, "IA32_MC0_ADDR" },
539 { 0x403, "IA32_MC0_MISC" },
540 { 0x404, "IA32_MC1_CTL" },
541 { 0x405, "IA32_MC1_STATUS" },
542 { 0x406, "IA32_MC1_ADDR" },
543 { 0x407, "IA32_MC1_MISC" },
544 { 0x408, "IA32_MC2_CTL" },
545 { 0x409, "IA32_MC2_STATUS" },
546 { 0x40a, "IA32_MC2_ADDR" },
547 { 0x40b, "IA32_MC2_MISC" },
548 { 0x40c, "IA32_MC3_CTL" },
549 { 0x40d, "IA32_MC3_STATUS" },
550 { 0x40e, "IA32_MC3_ADDR" },
551 { 0x40f, "IA32_MC3_MISC" },
552 { 0x410, "IA32_MC4_CTL" },
553 { 0x411, "IA32_MC4_STATUS" },
554 { 0x412, "IA32_MC4_ADDR" },
555 { 0x413, "IA32_MC4_MISC" },
556 };
557
558 static const msr_entry_t modelf2x_per_core_msrs[] = {
559 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
560 { 0x001b, "IA32_APIC_BASE" },
561 /* 0x3a: Not available in model 2. */
562 { 0x008b, "IA32_BIOS_SIGN_ID" },
563 /* 0x9b: Not available in model 2. */
564 { 0x00fe, "IA32_MTRRCAP" },
565 { 0x0174, "IA32_SYSENTER_CS" },
566 { 0x0175, "IA32_SYSENTER_ESP" },
567 { 0x0176, "IA32_SYSENTER_EIP" },
568 { 0x0179, "IA32_MCG_CAP" },
569 { 0x017a, "IA32_MCG_STATUS" },
570 { 0x017b, "IA32_MCG_CTL" },
571 { 0x0180, "MSR_MCG_RAX" },
572 { 0x0181, "MSR_MCG_RBX" },
573 { 0x0182, "MSR_MCG_RCX" },
574 { 0x0183, "MSR_MCG_RDX" },
575 { 0x0184, "MSR_MCG_RSI" },
576 { 0x0185, "MSR_MCG_RDI" },
577 { 0x0186, "MSR_MCG_RBP" },
578 { 0x0187, "MSR_MCG_RSP" },
579 { 0x0188, "MSR_MCG_RFLAGS" },
580 { 0x0189, "MSR_MCG_RIP" },
581 { 0x018a, "MSR_MCG_MISC" },
582 /* 0x18b-0x18f: Reserved */
583 { 0x0190, "MSR_MCG_R8" },
584 { 0x0191, "MSR_MCG_R9" },
585 { 0x0192, "MSR_MCG_R10" },
586 { 0x0193, "MSR_MCG_R11" },
587 { 0x0194, "MSR_MCG_R12" },
588 { 0x0195, "MSR_MCG_R13" },
589 { 0x0196, "MSR_MCG_R14" },
590 { 0x0197, "MSR_MCG_R15" },
591 /* 0x198: Not available in model 2. */
592 /* 0x199: Not available in model 2. */
593 { 0x019a, "IA32_CLOCK_MODULATION" },
594 { 0x019b, "IA32_THERM_INTERRUPT" },
595 { 0x01a0, "IA32_MISC_ENABLE" },
596 { 0x01d7, "MSR_LER_FROM_LIP" },
597 { 0x01d8, "MSR_LER_TO_LIP" },
598 { 0x01d9, "MSR_DEBUGCTLA" },
599 { 0x01da, "MSR_LASTBRANCH_TOS" },
600 { 0x01db, "MSR_LASTBRANCH_0" },
601 { 0x01dd, "MSR_LASTBRANCH_2" },
602 { 0x01de, "MSR_LASTBRANCH_3" },
603 { 0x0277, "IA32_PAT" },
604 /* 0x480-0x48b : Not available in model 2. */
605 { 0x0600, "IA32_DS_AREA" },
606 /* 0x0680 - 0x06cf Branch Records Skipped */
607 };
608
Pat Erleyca3548e2010-04-21 06:23:19 +0000609 static const msr_entry_t modelf4x_global_msrs[] = {
610 { 0x0000, "IA32_P5_MC_ADDR" },
611 { 0x0001, "IA32_P5_MC_TYPE" },
612 { 0x0006, "IA32_MONITOR_FILTER_LINE_SIZE" },
613 { 0x0017, "IA32_PLATFORM_ID" },
614 { 0x002a, "MSR_EBC_HARD_POWERON" },
615 { 0x002b, "MSR_EBC_SOFT_POWRON" },
616 { 0x002c, "MSR_EBC_FREQUENCY_ID" },
Stefan Reinauer14e22772010-04-27 06:56:47 +0000617// WRITE ONLY { 0x0079, "IA32_BIOS_UPDT_TRIG" },
Pat Erleyca3548e2010-04-21 06:23:19 +0000618 { 0x019c, "IA32_THERM_STATUS" },
619 { 0x019d, "MSR_THERM2_CTL" },
620 { 0x01a0, "IA32_MISC_ENABLE" },
621 { 0x01a1, "MSR_PLATFORM_BRV" },
622 { 0x0200, "IA32_MTRR_PHYSBASE0" },
623 { 0x0201, "IA32_MTRR_PHYSMASK0" },
624 { 0x0202, "IA32_MTRR_PHYSBASE1" },
625 { 0x0203, "IA32_MTRR_PHYSMASK1" },
626 { 0x0204, "IA32_MTRR_PHYSBASE2" },
627 { 0x0205, "IA32_MTRR_PHYSMASK2" },
628 { 0x0206, "IA32_MTRR_PHYSBASE3" },
629 { 0x0207, "IA32_MTRR_PHYSMASK3" },
630 { 0x0208, "IA32_MTRR_PHYSBASE4" },
631 { 0x0209, "IA32_MTRR_PHYSMASK4" },
632 { 0x020a, "IA32_MTRR_PHYSBASE5" },
633 { 0x020b, "IA32_MTRR_PHYSMASK5" },
634 { 0x020c, "IA32_MTRR_PHYSBASE6" },
635 { 0x020d, "IA32_MTRR_PHYSMASK6" },
636 { 0x020e, "IA32_MTRR_PHYSBASE7" },
637 { 0x020f, "IA32_MTRR_PHYSMASK7" },
638 { 0x0250, "IA32_MTRR_FIX64K_00000" },
639 { 0x0258, "IA32_MTRR_FIX16K_80000" },
640 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
641 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
642 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
643 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
644 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
645 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
646 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
647 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
648 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
649 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
650 { 0x0300, "MSR_BPU_COUNTER0" },
651 { 0x0301, "MSR_BPU_COUNTER1" },
652 { 0x0302, "MSR_BPU_COUNTER2" },
653 { 0x0303, "MSR_BPU_COUNTER3" },
654 /* Skipped through 0x3ff for now*/
655
Stefan Reinauer14e22772010-04-27 06:56:47 +0000656 /* All MCX_ADDR AND MCX_MISC MSRs depend on a bit being
Pat Erleyca3548e2010-04-21 06:23:19 +0000657 * set in MCX_STATUS */
658 { 0x400, "IA32_MC0_CTL" },
659 { 0x401, "IA32_MC0_STATUS" },
660 { 0x402, "IA32_MC0_ADDR" },
661 { 0x403, "IA32_MC0_MISC" },
662 { 0x404, "IA32_MC1_CTL" },
663 { 0x405, "IA32_MC1_STATUS" },
664 { 0x406, "IA32_MC1_ADDR" },
Stefan Reinauer14e22772010-04-27 06:56:47 +0000665 { 0x407, "IA32_MC1_MISC" },
Pat Erleyca3548e2010-04-21 06:23:19 +0000666 { 0x408, "IA32_MC2_CTL" },
667 { 0x409, "IA32_MC2_STATUS" },
668 { 0x40a, "IA32_MC2_ADDR" },
669 { 0x40b, "IA32_MC2_MISC" },
670 { 0x40c, "IA32_MC3_CTL" },
671 { 0x40d, "IA32_MC3_STATUS" },
672 { 0x40e, "IA32_MC3_ADDR" },
673 { 0x40f, "IA32_MC3_MISC" },
674 { 0x410, "IA32_MC4_CTL" },
675 { 0x411, "IA32_MC4_STATUS" },
676 { 0x412, "IA32_MC4_ADDR" },
677 { 0x413, "IA32_MC4_MISC" },
678 };
679
680 static const msr_entry_t modelf4x_per_core_msrs[] = {
681 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
682 { 0x001b, "IA32_APIC_BASE" },
683 { 0x003a, "IA32_FEATURE_CONTROL" },
684 { 0x008b, "IA32_BIOS_SIGN_ID" },
685 { 0x009b, "IA32_SMM_MONITOR_CTL" },
686 { 0x00fe, "IA32_MTRRCAP" },
687 { 0x0174, "IA32_SYSENTER_CS" },
688 { 0x0175, "IA32_SYSENTER_ESP" },
689 { 0x0176, "IA32_SYSENTER_EIP" },
690 { 0x0179, "IA32_MCG_CAP" },
691 { 0x017a, "IA32_MCG_STATUS" },
692 { 0x0180, "MSR_MCG_RAX" },
693 { 0x0181, "MSR_MCG_RBX" },
694 { 0x0182, "MSR_MCG_RCX" },
695 { 0x0183, "MSR_MCG_RDX" },
696 { 0x0184, "MSR_MCG_RSI" },
697 { 0x0185, "MSR_MCG_RDI" },
698 { 0x0186, "MSR_MCG_RBP" },
699 { 0x0187, "MSR_MCG_RSP" },
700 { 0x0188, "MSR_MCG_RFLAGS" },
701 { 0x0189, "MSR_MCG_RIP" },
702 { 0x018a, "MSR_MCG_MISC" },
703 // 0x18b-f Reserved
704 { 0x0190, "MSR_MCG_R8" },
705 { 0x0191, "MSR_MCG_R9" },
706 { 0x0192, "MSR_MCG_R10" },
707 { 0x0193, "MSR_MCG_R11" },
708 { 0x0194, "MSR_MCG_R12" },
709 { 0x0195, "MSR_MCG_R13" },
710 { 0x0196, "MSR_MCG_R14" },
711 { 0x0197, "MSR_MCG_R15" },
712 { 0x0198, "IA32_PERF_STATUS" },
713 { 0x0199, "IA32_PERF_CTL" },
714 { 0x019a, "IA32_CLOCK_MODULATION" },
715 { 0x019b, "IA32_THERM_INTERRUPT" },
716 { 0x01a0, "IA32_MISC_ENABLE" }, // Bit 34 is Core Specific
717 { 0x01d7, "MSR_LER_FROM_LIP" },
718 { 0x01d8, "MSR_LER_TO_LIP" },
719 { 0x01d9, "MSR_DEBUGCTLA" },
720 { 0x01da, "MSR_LASTBRANCH_TOS" },
721 { 0x0277, "IA32_PAT" },
722 /** Virtualization
723 { 0x480, "IA32_VMX_BASIC" },
724 through
725 { 0x48b, "IA32_VMX_PROCBASED_CTLS2" },
726 Not implemented in my CPU
727 */
728 { 0x0600, "IA32_DS_AREA" },
729 /* 0x0680 - 0x06cf Branch Records Skipped */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000730
Pat Erleyca3548e2010-04-21 06:23:19 +0000731 };
732
Stefan Reinauer23190272008-08-20 13:41:24 +0000733 typedef struct {
734 unsigned int model;
735 const msr_entry_t *global_msrs;
736 unsigned int num_global_msrs;
737 const msr_entry_t *per_core_msrs;
738 unsigned int num_per_core_msrs;
739 } cpu_t;
740
741 cpu_t cpulist[] = {
Tobias Diedrich3645e612010-11-27 14:44:19 +0000742 { 0x00670, model67x_global_msrs, ARRAY_SIZE(model67x_global_msrs), NULL, 0 },
Stefan Reinauer04844812010-02-22 11:26:06 +0000743 { 0x006b0, model6bx_global_msrs, ARRAY_SIZE(model6bx_global_msrs), NULL, 0 },
Stefan Reinauer23190272008-08-20 13:41:24 +0000744 { 0x006e0, model6ex_global_msrs, ARRAY_SIZE(model6ex_global_msrs), model6ex_per_core_msrs, ARRAY_SIZE(model6ex_per_core_msrs) },
745 { 0x006f0, model6fx_global_msrs, ARRAY_SIZE(model6fx_global_msrs), model6fx_per_core_msrs, ARRAY_SIZE(model6fx_per_core_msrs) },
Idwer Vollering312fc962010-12-17 22:34:58 +0000746 { 0x00f20, modelf2x_global_msrs, ARRAY_SIZE(modelf2x_global_msrs), modelf2x_per_core_msrs, ARRAY_SIZE(modelf2x_per_core_msrs) },
Pat Erleyca3548e2010-04-21 06:23:19 +0000747 { 0x00f40, modelf4x_global_msrs, ARRAY_SIZE(modelf4x_global_msrs), modelf4x_per_core_msrs, ARRAY_SIZE(modelf4x_per_core_msrs) },
Stefan Reinauer23190272008-08-20 13:41:24 +0000748 };
749
750 cpu_t *cpu = NULL;
751
Stefan Reinauer14e22772010-04-27 06:56:47 +0000752 /* Get CPU family and model, not the stepping
Stefan Reinauer23190272008-08-20 13:41:24 +0000753 * (TODO: extended family/model)
754 */
Stefan Reinauer74cd56982010-06-01 10:04:28 +0000755 id = cpuid(1) & 0xfffff0;
Stefan Reinauer23190272008-08-20 13:41:24 +0000756 for (i = 0; i < ARRAY_SIZE(cpulist); i++) {
757 if(cpulist[i].model == id) {
758 cpu = &cpulist[i];
759 break;
760 }
761 }
762
763 if (!cpu) {
764 printf("Error: Dumping MSRs on this CPU (0x%06x) is not (yet) supported.\n", id);
765 return -1;
766 }
767
Stefan Reinauerf7f2f252009-09-01 09:52:14 +0000768#ifndef __DARWIN__
Stefan Reinauer23190272008-08-20 13:41:24 +0000769 fd_msr = open("/dev/cpu/0/msr", O_RDWR);
770 if (fd_msr < 0) {
771 perror("Error while opening /dev/cpu/0/msr");
772 printf("Did you run 'modprobe msr'?\n");
773 return -1;
774 }
Stefan Reinauer1162f252008-12-04 15:18:20 +0000775#endif
Stefan Reinauer23190272008-08-20 13:41:24 +0000776
777 printf("\n===================== SHARED MSRs (All Cores) =====================\n");
778
779 for (i = 0; i < cpu->num_global_msrs; i++) {
780 msr = rdmsr(cpu->global_msrs[i].number);
781 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
782 cpu->global_msrs[i].number, msr.hi, msr.lo,
783 cpu->global_msrs[i].name);
784 }
785
786 close(fd_msr);
787
788 for (core = 0; core < 8; core++) {
Stefan Reinauerf7f2f252009-09-01 09:52:14 +0000789#ifndef __DARWIN__
Stefan Reinauer23190272008-08-20 13:41:24 +0000790 char msrfilename[64];
791 memset(msrfilename, 0, 64);
792 sprintf(msrfilename, "/dev/cpu/%d/msr", core);
793
794 fd_msr = open(msrfilename, O_RDWR);
795
796 /* If the file is not there, we're probably through. No error,
797 * since we successfully opened /dev/cpu/0/msr before.
798 */
799 if (fd_msr < 0)
800 break;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000801#endif
Stefan Reinauer04844812010-02-22 11:26:06 +0000802 if (cpu->num_per_core_msrs)
803 printf("\n====================== UNIQUE MSRs (core %d) ======================\n", core);
Stefan Reinauer23190272008-08-20 13:41:24 +0000804
805 for (i = 0; i < cpu->num_per_core_msrs; i++) {
806 msr = rdmsr(cpu->per_core_msrs[i].number);
807 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
808 cpu->per_core_msrs[i].number, msr.hi, msr.lo,
809 cpu->per_core_msrs[i].name);
810 }
Stefan Reinauerf7f2f252009-09-01 09:52:14 +0000811#ifndef __DARWIN__
Stefan Reinauer23190272008-08-20 13:41:24 +0000812 close(fd_msr);
Stefan Reinauer1162f252008-12-04 15:18:20 +0000813#endif
Stefan Reinauer23190272008-08-20 13:41:24 +0000814 }
815
Stefan Reinauerf7f2f252009-09-01 09:52:14 +0000816#ifndef __DARWIN__
Stefan Reinauer23190272008-08-20 13:41:24 +0000817 if (msr_readerror)
818 printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
Stefan Reinauer1162f252008-12-04 15:18:20 +0000819#endif
Stefan Reinauer23190272008-08-20 13:41:24 +0000820 return 0;
821}