/* * Test program for reading current MTRR values * * (C) 2007 Bernhard Kaindl * (C) 2000 Dave Jones, Arjan van de Ven. */ #include #include /* rdmsr - read MSR, taken from Powertweak Linux * (C) 2000 Dave Jones, Arjan van de Ven. * Licensed under the terms of the GNU GPL License version 2. */ int rdmsr(int cpu, unsigned long msrindex, unsigned long long *val) { char cpuname[36]; int fh, ret; snprintf (cpuname,15, "/dev/cpu/%d/msr", cpu); fh = open (cpuname, 0); if (fh==-1) ret = -1; else { lseek (fh, msrindex, SEEK_SET); ret = (read (fh, val, 8) == 8); close (fh); } return ret; } int print_msr_cpu(int cpu, int reg) { unsigned long long val; int ret; if ((ret = rdmsr(cpu, reg, &val)) > 0) printf("%016llx", val); return ret; } print_msr(int reg) { int i = 1, cpu = 0; printf("MSR 0x%03x: ", reg); if (print_msr_cpu(cpu++, reg) <= 0) printf("read error - Is msr.ko loaded and are the devices created?\n"); while (cpu < 16) { printf(" | "); if (print_msr_cpu(cpu++, reg) <= 0) break; } printf("\n"); } main() { int i; print_msr(0x250); print_msr(0x258); print_msr(0x259); for (i=0x268; i<0x270; i++) print_msr(i); }