Hello community, here is the log from the commit of package msr-tools for openSUSE:Factory checked in at 2013-11-26 19:19:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/msr-tools (Old) and /work/SRC/openSUSE:Factory/.msr-tools.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "msr-tools" Changes: -------- --- /work/SRC/openSUSE:Factory/msr-tools/msr-tools.changes 2011-09-23 02:13:34.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.msr-tools.new/msr-tools.changes 2013-11-26 19:19:57.000000000 +0100 @@ -1,0 +2,6 @@ +Tue Nov 26 15:43:18 UTC 2013 - [email protected] + +- Update to latest version 1.3 (cpuid tool added) + bnc#847158 + +------------------------------------------------------------------- Old: ---- msr-tools-1.2.tar.bz2 New: ---- msr-tools-1.3.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ msr-tools.spec ++++++ --- /var/tmp/diff_new_pack.QEyumL/_old 2013-11-26 19:19:58.000000000 +0100 +++ /var/tmp/diff_new_pack.QEyumL/_new 2013-11-26 19:19:58.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package msr-tools # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,9 +19,9 @@ Name: msr-tools -Url: http://www.kernel.org/pub/linux/utils/cpu/msr-tools/ +Url: https://github.com/01org/msr-tools Summary: Tool for reading and writing MSRs (model specific register) -Version: 1.2 +Version: 1.3 Release: 1 License: GPL-2.0+ Group: System/Base @@ -53,7 +53,7 @@ %install mkdir -p $RPM_BUILD_ROOT/%{_sbindir} cp %{SOURCE1} . -install -m 0755 rdmsr wrmsr $RPM_BUILD_ROOT/%{_sbindir} +install -m 0755 rdmsr wrmsr cpuid $RPM_BUILD_ROOT/%{_sbindir} %clean rm -rf %{buildroot} ++++++ msr-tools-1.2.tar.bz2 -> msr-tools-1.3.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msr-tools-1.2/.gitignore new/msr-tools-1.3/.gitignore --- old/msr-tools-1.2/.gitignore 2010-08-05 08:35:51.000000000 +0200 +++ new/msr-tools-1.3/.gitignore 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -rdmsr -wrmsr -*.o -*~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msr-tools-1.2/Makefile new/msr-tools-1.3/Makefile --- old/msr-tools-1.2/Makefile 2010-08-05 08:35:51.000000000 +0200 +++ new/msr-tools-1.3/Makefile 2013-09-10 04:49:29.000000000 +0200 @@ -18,7 +18,7 @@ CFLAGS = -g -O2 -fomit-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 LDFLAGS = -BIN = wrmsr rdmsr +BIN = wrmsr rdmsr cpuid sbindir = /usr/sbin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msr-tools-1.2/cpuid.c new/msr-tools-1.3/cpuid.c --- old/msr-tools-1.2/cpuid.c 1970-01-01 01:00:00.000000000 +0100 +++ new/msr-tools-1.3/cpuid.c 2013-09-10 04:49:29.000000000 +0200 @@ -0,0 +1,201 @@ +/* + * Utility to read CPUIDs from x86 processors + * Copyright (c) 2013, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <stdio.h> +#include <ctype.h> +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +struct cpuid { + uint32_t eax, ebx, ecx, edx; +}; + +static int cpuid(int cpu, uint32_t leaf, uint32_t subleaf, struct cpuid *data) +{ + static int fd = -1; + static int last_cpu; + off_t offset = leaf + ((off_t) subleaf << 32); + + if (fd < 0 || last_cpu != cpu) { + char devstr[64]; + if (fd >= 0) + close(fd); + snprintf(devstr, sizeof devstr, "/dev/cpu/%d/cpuid", cpu); + fd = open(devstr, O_RDONLY); + if (fd < 0) { + if (errno == ENXIO) { + fprintf(stderr, "cpuid: No CPU %d\n", cpu); + exit(2); + } else if (errno == EIO) { + fprintf(stderr, + "cpuid: CPU %d doesn't support cpuid\n", + cpu); + exit(3); + } else { + perror("cpuid: open"); + exit(127); + } + } + last_cpu = cpu; + } + return pread(fd, data, sizeof(*data), offset) == sizeof(*data) ? 0 : -1; +} + +static char *make_string(uint32_t val) +{ + static char string[5] = "xxxx"; + int i, ch; + + for (i = 0; i < 4; i++) { + ch = val & 0xff; + string[i] = isprint(ch) ? ch : '.'; + val >>= 8; + } + + return string; +} + +static void print_cpuid_level(uint32_t leaf, uint32_t subleaf, + struct cpuid *lvl) +{ + printf("%08x %08x: ", leaf, subleaf); + printf("%08x %s ", lvl->eax, make_string(lvl->eax)); + printf("%08x %s ", lvl->ebx, make_string(lvl->ebx)); + printf("%08x %s ", lvl->ecx, make_string(lvl->ecx)); + printf("%08x %s\n", lvl->edx, make_string(lvl->edx)); +} + +static void dump_cpuid_leaf(int cpu, uint32_t leaf) +{ + struct cpuid lvl, lastlvl, lvl0; + uint32_t subleaf; + + cpuid(cpu, leaf, 0, &lvl0); + print_cpuid_level(leaf, 0, &lvl0); + + /* + * There is no standard mechanism for enumerating the number of + * subleaves, this is a heuristic... + */ + lastlvl = lvl0; + + for (subleaf = 1; subleaf != 0; subleaf++) { + if (cpuid(cpu, leaf, subleaf, &lvl)) + return; + + switch (leaf) { + case 4: + if ((lvl.eax & 0x1f) == 0 + || !memcmp(&lvl, &lastlvl, sizeof lvl)) + return; + break; + + case 7: + if (subleaf >= lvl0.eax) + return; + break; + + case 0xb: + if ((lvl.ecx & ~0xff) == 0) + return; + + case 0xd: + if ((lvl.eax | lvl.ebx | lvl.ecx | lvl.edx) == 0) + return; + + default: + /* Generic, anticipatory rules */ + /* Exclude ecx here for levels which return the initial ecx value */ + if ((lvl.eax | lvl.ebx | lvl.ecx | lvl.edx) == 0) + return; + + if (!memcmp(&lvl, &lvl0, sizeof lvl)) + return; + break; + } + + print_cpuid_level(leaf, subleaf, &lvl); + + lastlvl = lvl; + } +} + +static void dump_levels(int cpu, uint32_t region) +{ + static struct cpuid invalid_leaf; + struct cpuid max; + uint32_t n; + + if (cpuid(cpu, region, 0, &max)) + return; + + /* + * Intel processors may return the last group 0 CPUID leaf instead + * all zero for a not-present level + */ + if (region == 0) { + cpuid(cpu, max.eax + 1, 0, &invalid_leaf); + } else { + if (!memcmp(&max, &invalid_leaf, sizeof(struct cpuid))) + return; + } + + if ((max.eax & 0xffff0000) == region) { + for (n = region; n <= max.eax; n++) { + dump_cpuid_leaf(cpu, n); + } + } +} + +void usage(void) +{ + fprintf(stderr, "Usage: cpuid [processor # (default 0)]\n"); +} + +int main(int argc, char *argv[]) +{ + int cpu = 0; + uint32_t n; + char *endptr; + + if (argc > 2) { + usage(); + exit(127); + } else if (argc == 2) { + cpu = strtoul(argv[1], &endptr, 0); + if (*endptr || cpu > 255) { + usage(); + exit(127); + } + } + + printf + ("Leaf Subleaf EAX EBX ECX EDX \n"); + + for (n = 0; n <= 0xffff; n++) { + dump_levels(cpu, n << 16); + } + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msr-tools-1.2/rdmsr.c new/msr-tools-1.3/rdmsr.c --- old/msr-tools-1.2/rdmsr.c 2010-08-05 08:35:51.000000000 +0200 +++ new/msr-tools-1.3/rdmsr.c 2013-09-10 04:49:29.000000000 +0200 @@ -25,6 +25,8 @@ #include <getopt.h> #include <inttypes.h> #include <sys/types.h> +#include <dirent.h> +#include <ctype.h> #include "version.h" @@ -49,11 +51,9 @@ }; static const char short_options[] = "hVxXdoruc0ap:f:"; -static const char *proc_stat = "/proc/stat"; - /* Number of decimal digits for a certain number of bits */ /* (int) ceil(log(2^n)/log(10)) */ -static const int decdigits[] = { +int decdigits[] = { 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, @@ -73,7 +73,7 @@ const char *program; -static void usage(void) +void usage(void) { fprintf(stderr, "Usage: %s [options] regno\n" @@ -92,13 +92,118 @@ " --bitfield h:l -f Output bits [h:l] only\n", program); } -struct format { - unsigned int mode; - unsigned int highbit; - unsigned int lowbit; -}; +void rdmsr_on_cpu(uint32_t reg, int cpu); + +/* filter out ".", "..", "microcode" in /dev/cpu */ +int dir_filter(const struct dirent *dirp) { + if (isdigit(dirp->d_name[0])) + return 1; + else + return 0; +} + +void rdmsr_on_all_cpus(uint32_t reg) +{ + struct dirent **namelist; + int dir_entries; + + dir_entries = scandir("/dev/cpu", &namelist, dir_filter, 0); + while (dir_entries--) { + rdmsr_on_cpu(reg, atoi(namelist[dir_entries]->d_name)); + free(namelist[dir_entries]); + } + free(namelist); +} + +unsigned int highbit = 63, lowbit = 0; +int mode = mo_hex; + +int main(int argc, char *argv[]) +{ + uint32_t reg; + int c; + int cpu = 0; + unsigned long arg; + char *endarg; + + program = argv[0]; + + while ((c = + getopt_long(argc, argv, short_options, long_options, + NULL)) != -1) { + switch (c) { + case 'h': + usage(); + exit(0); + case 'V': + fprintf(stderr, "%s: version %s\n", program, + VERSION_STRING); + exit(0); + case 'x': + mode = (mode & ~mo_mask) | mo_hex; + break; + case 'X': + mode = (mode & ~mo_mask) | mo_chx; + break; + case 'o': + mode = (mode & ~mo_mask) | mo_oct; + break; + case 'd': + mode = (mode & ~mo_mask) | mo_dec; + break; + case 'r': + mode = (mode & ~mo_mask) | mo_raw; + break; + case 'u': + mode = (mode & ~mo_mask) | mo_uns; + break; + case 'c': + mode |= mo_c; + break; + case '0': + mode |= mo_fill; + break; + case 'a': + cpu = -1; + break; + case 'p': + arg = strtoul(optarg, &endarg, 0); + if (*endarg || arg > 255) { + usage(); + exit(127); + } + cpu = (int)arg; + break; + case 'f': + if (sscanf(optarg, "%u:%u", &highbit, &lowbit) != 2 || + highbit > 63 || lowbit > highbit) { + usage(); + exit(127); + } + break; + default: + usage(); + exit(127); + } + } + + if (optind != argc - 1) { + /* Should have exactly one argument */ + usage(); + exit(127); + } + + reg = strtoul(argv[optind], NULL, 0); + + if (cpu == -1) { + rdmsr_on_all_cpus(reg); + } + else + rdmsr_on_cpu(reg, cpu); + exit(0); +} -static void rdmsr_on_cpu(const struct format *fmt, uint32_t reg, int cpu) +void rdmsr_on_cpu(uint32_t reg, int cpu) { uint64_t data; int fd; @@ -137,17 +242,17 @@ close(fd); - bits = fmt->highbit - fmt->lowbit + 1; + bits = highbit - lowbit + 1; if (bits < 64) { /* Show only part of register */ - data >>= fmt->lowbit; + data >>= lowbit; data &= (1ULL << bits) - 1; } pat = NULL; width = 1; /* Default */ - switch (fmt->mode) { + switch (mode) { case mo_hex: pat = "%*llx\n"; break; @@ -249,123 +354,3 @@ printf(pat, width, data); return; } - -static void rdmsr_on_all_cpus(const struct format *fmt, uint32_t reg) -{ - FILE *fp; - int retval; - - fp = fopen(proc_stat, "r"); - if (fp == NULL) { - perror(proc_stat); - exit(-1); - } - - retval = fscanf(fp, "cpu %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d\n"); - if (retval != 0) { - perror("/proc/stat format"); - exit(-1); - } - - for (;;) { - int cpu; - - retval = fscanf(fp, "cpu%u %*d %*d %*d %*d %*d %*d %*d %*d %*d" - " %*d\n", &cpu); - if (retval != 1) - return; - - rdmsr_on_cpu(fmt, reg, cpu); - } - fclose(fp); -} - -int main(int argc, char *argv[]) -{ - uint32_t reg; - int c; - int cpu = 0; - unsigned long arg; - char *endarg; - struct format fmt; - - fmt.mode = mo_hex; - fmt.highbit = 63; - fmt.lowbit = 0; - - program = argv[0]; - - while ((c = getopt_long(argc, argv, short_options, - long_options, NULL)) != -1) { - switch (c) { - case 'h': - usage(); - exit(0); - case 'V': - fprintf(stderr, "%s: version %s\n", program, - VERSION_STRING); - exit(0); - case 'x': - fmt.mode = (fmt.mode & ~mo_mask) | mo_hex; - break; - case 'X': - fmt.mode = (fmt.mode & ~mo_mask) | mo_chx; - break; - case 'o': - fmt.mode = (fmt.mode & ~mo_mask) | mo_oct; - break; - case 'd': - fmt.mode = (fmt.mode & ~mo_mask) | mo_dec; - break; - case 'r': - fmt.mode = (fmt.mode & ~mo_mask) | mo_raw; - break; - case 'u': - fmt.mode = (fmt.mode & ~mo_mask) | mo_uns; - break; - case 'c': - fmt.mode |= mo_c; - break; - case '0': - fmt.mode |= mo_fill; - break; - case 'a': - cpu = -1; - break; - case 'p': - arg = strtoul(optarg, &endarg, 0); - if (*endarg || arg > 255) { - usage(); - exit(127); - } - cpu = (int)arg; - break; - case 'f': - if (sscanf(optarg, "%u:%u", &fmt.highbit, &fmt.lowbit) - != 2 || - fmt.highbit > 63 || - fmt.lowbit > fmt.highbit) { - usage(); - exit(127); - } - break; - default: - usage(); - exit(127); - } - } - - if (optind != argc - 1) { - /* Should have exactly one argument */ - usage(); - exit(127); - } - - reg = strtoul(argv[optind], NULL, 0); - - if (cpu == -1) - rdmsr_on_all_cpus(&fmt, reg); - else - rdmsr_on_cpu(&fmt, reg, cpu); - exit(0); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msr-tools-1.2/version.h new/msr-tools-1.3/version.h --- old/msr-tools-1.2/version.h 2010-08-05 08:35:51.000000000 +0200 +++ new/msr-tools-1.3/version.h 2013-09-10 04:49:29.000000000 +0200 @@ -1,4 +1,4 @@ #ifndef MSR_TOOLS_VERSION_H #define MSR_TOOLS_VERSION_H -#define VERSION_STRING "msr-tools-1.2" +#define VERSION_STRING "msr-tools-1.3" #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msr-tools-1.2/wrmsr.c new/msr-tools-1.3/wrmsr.c --- old/msr-tools-1.2/wrmsr.c 2010-08-05 08:35:51.000000000 +0200 +++ new/msr-tools-1.3/wrmsr.c 2013-09-10 04:49:29.000000000 +0200 @@ -25,6 +25,8 @@ #include <getopt.h> #include <inttypes.h> #include <sys/types.h> +#include <dirent.h> +#include <ctype.h> #include "version.h" @@ -38,10 +40,9 @@ }; static const char short_options[] = "hVap:"; -static const char *proc_stat = "/proc/stat"; const char *program; -static void usage(void) +void usage(void) { fprintf(stderr, "Usage: %s [options] regno value...\n" " --help -h Print this help\n" @@ -51,76 +52,34 @@ program); } -static void wrmsr_on_cpu(uint32_t reg, uint64_t data, int cpu) -{ - int fd; - char msr_file_name[64]; +void wrmsr_on_cpu(uint32_t reg, int cpu, int valcnt, char *regvals[]); - sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); - fd = open(msr_file_name, O_WRONLY); - if (fd < 0) { - if (errno == ENXIO) { - fprintf(stderr, "wrmsr: No CPU %d\n", cpu); - exit(2); - } else if (errno == EIO) { - fprintf(stderr, "wrmsr: CPU %d doesn't support MSRs\n", - cpu); - exit(3); - } else { - perror("wrmsr: open"); - exit(127); - } - } - if (pwrite(fd, &data, sizeof data, reg) != sizeof data) { - if (errno == EIO) { - fprintf(stderr, - "wrmsr: CPU %d cannot set MSR " - "0x%08"PRIx32" to 0x%016"PRIx64"\n", - cpu, reg, data); - exit(4); - } else { - perror("wrmsr: pwrite"); - exit(127); - } - } - close(fd); +/* filter out ".", "..", "microcode" in /dev/cpu */ +int dir_filter(const struct dirent *dirp) +{ + if (isdigit(dirp->d_name[0])) + return 1; + else + return 0; } - -static void wrmsr_on_all_cpus(uint32_t reg, uint64_t data) +void wrmsr_on_all_cpus(uint32_t reg, int valcnt, char *regvals[]) { - FILE *fp; - int retval; - - fp = fopen(proc_stat, "r"); - if (fp == NULL) { - perror(proc_stat); - exit(-1); - } - - retval = fscanf(fp, "cpu %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d\n"); - if (retval != 0) { - perror("/proc/stat format"); - exit(-1); - } - - for (;;) { - int cpu; + struct dirent **namelist; + int dir_entries; - retval = fscanf(fp, "cpu%u %*d %*d %*d %*d %*d %*d %*d %*d " - "%*d %*d\n", &cpu); - if (retval != 1) - return; - - wrmsr_on_cpu(reg, data, cpu); + dir_entries = scandir("/dev/cpu", &namelist, dir_filter, 0); + while (dir_entries--) { + wrmsr_on_cpu(reg, atoi(namelist[dir_entries]->d_name), + valcnt, regvals); + free(namelist[dir_entries]); } - fclose(fp); + free(namelist); } int main(int argc, char *argv[]) { uint32_t reg; - uint64_t data; int c; int cpu = 0; unsigned long arg; @@ -163,12 +122,54 @@ reg = strtoul(argv[optind++], NULL, 0); - while (optind < argc) { - data = strtoull(argv[optind++], NULL, 0); - if (cpu == -1) - wrmsr_on_all_cpus(reg, data); - else - wrmsr_on_cpu(reg, data, cpu); + if (cpu == -1) { + wrmsr_on_all_cpus(reg, argc - optind, &argv[optind]); + } else { + wrmsr_on_cpu(reg, cpu, argc - optind, &argv[optind]); } + exit(0); } + +void wrmsr_on_cpu(uint32_t reg, int cpu, int valcnt, char *regvals[]) +{ + uint64_t data; + int fd; + char msr_file_name[64]; + + sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); + fd = open(msr_file_name, O_WRONLY); + if (fd < 0) { + if (errno == ENXIO) { + fprintf(stderr, "wrmsr: No CPU %d\n", cpu); + exit(2); + } else if (errno == EIO) { + fprintf(stderr, "wrmsr: CPU %d doesn't support MSRs\n", + cpu); + exit(3); + } else { + perror("wrmsr: open"); + exit(127); + } + } + + while (valcnt--) { + data = strtoull(*regvals++, NULL, 0); + if (pwrite(fd, &data, sizeof data, reg) != sizeof data) { + if (errno == EIO) { + fprintf(stderr, + "wrmsr: CPU %d cannot set MSR " + "0x%08"PRIx32" to 0x%016"PRIx64"\n", + cpu, reg, data); + exit(4); + } else { + perror("wrmsr: pwrite"); + exit(127); + } + } + } + + close(fd); + + return; +} ++++++ msr-tools-xen_physical_msr_support.patch ++++++ --- /var/tmp/diff_new_pack.QEyumL/_old 2013-11-26 19:19:58.000000000 +0100 +++ /var/tmp/diff_new_pack.QEyumL/_new 2013-11-26 19:19:58.000000000 +0100 @@ -14,11 +14,11 @@ wrmsr.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) -diff --git a/rdmsr.c b/rdmsr.c -index 3f5e2b3..f0543b8 100644 ---- a/rdmsr.c -+++ b/rdmsr.c -@@ -42,15 +42,18 @@ static const struct option long_options[] = { +Index: msr-tools-1.3/rdmsr.c +=================================================================== +--- msr-tools-1.3.orig/rdmsr.c ++++ msr-tools-1.3/rdmsr.c +@@ -45,12 +45,15 @@ static const struct option long_options[ {"zero-pad", 0, 0, '0'}, {"raw", 0, 0, 'r'}, {"all", 0, 0, 'a'}, @@ -30,15 +30,12 @@ }; -static const char short_options[] = "hVxXdoruc0ap:f:"; +static const char short_options[] = "hVxXdoruc0aP:p:f:"; - - static const char *proc_stat = "/proc/stat"; - -+static const char *msr_file_pattern = "/dev/cpu/%d/msr"; + ++static const char *msr_file_pattern = "/dev/cpu/%d/msr"; + /* Number of decimal digits for a certain number of bits */ /* (int) ceil(log(2^n)/log(10)) */ - static const int decdigits[] = { -@@ -89,6 +92,7 @@ static void usage(void) +@@ -90,6 +93,7 @@ void usage(void) " --raw -r Raw binary output\n" " --all -a all processors\n" " --processor # -p Select processor number (default 0)\n" @@ -46,16 +43,7 @@ " --bitfield h:l -f Output bits [h:l] only\n", program); } -@@ -107,7 +111,7 @@ static void rdmsr_on_cpu(const struct format *fmt, uint32_t reg, int cpu) - char msr_file_name[64]; - unsigned int bits; - -- sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); -+ sprintf(msr_file_name, msr_file_pattern, cpu); - fd = open(msr_file_name, O_RDONLY); - if (fd < 0) { - if (errno == ENXIO) { -@@ -332,6 +336,9 @@ int main(int argc, char *argv[]) +@@ -167,6 +171,9 @@ int main(int argc, char *argv[]) case 'a': cpu = -1; break; @@ -65,11 +53,20 @@ case 'p': arg = strtoul(optarg, &endarg, 0); if (*endarg || arg > 255) { -diff --git a/wrmsr.c b/wrmsr.c -index 9800841..cb4a7e4 100644 ---- a/wrmsr.c -+++ b/wrmsr.c -@@ -33,12 +33,16 @@ static const struct option long_options[] = { +@@ -213,7 +220,7 @@ void rdmsr_on_cpu(uint32_t reg, int cpu) + char msr_file_name[64]; + unsigned int bits; + +- sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); ++ sprintf(msr_file_name, msr_file_pattern, cpu); + fd = open(msr_file_name, O_RDONLY); + if (fd < 0) { + if (errno == ENXIO) { +Index: msr-tools-1.3/wrmsr.c +=================================================================== +--- msr-tools-1.3.orig/wrmsr.c ++++ msr-tools-1.3/wrmsr.c +@@ -36,10 +36,13 @@ static const struct option long_options[ {"version", 0, 0, 'V'}, {"all", 0, 0, 'a'}, {"processor", 1, 0, 'p'}, @@ -79,15 +76,12 @@ }; -static const char short_options[] = "hVap:"; +static const char short_options[] = "hVaP:p:"; - - static const char *proc_stat = "/proc/stat"; + +static const char *msr_file_pattern = "/dev/cpu/%d/msr"; -+ + const char *program; - static void usage(void) -@@ -47,6 +51,7 @@ static void usage(void) +@@ -49,6 +52,7 @@ void usage(void) " --help -h Print this help\n" " --version -V Print current version\n" " --all -a all processors\n" @@ -95,16 +89,7 @@ " --processor # -p Select processor number (default 0)\n", program); } -@@ -56,7 +61,7 @@ static void wrmsr_on_cpu(uint32_t reg, uint64_t data, int cpu) - int fd; - char msr_file_name[64]; - -- sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); -+ sprintf(msr_file_name, msr_file_pattern, cpu); - fd = open(msr_file_name, O_WRONLY); - if (fd < 0) { - if (errno == ENXIO) { -@@ -141,6 +146,9 @@ int main(int argc, char *argv[]) +@@ -101,6 +105,9 @@ int main(int argc, char *argv[]) case 'a': cpu = -1; break; @@ -114,3 +99,12 @@ case 'p': arg = strtoul(optarg, &endarg, 0); if (*endarg || arg > 255) { +@@ -138,7 +145,7 @@ void wrmsr_on_cpu(uint32_t reg, int cpu, + int fd; + char msr_file_name[64]; + +- sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); ++ sprintf(msr_file_name, msr_file_pattern, cpu); + fd = open(msr_file_name, O_WRONLY); + if (fd < 0) { + if (errno == ENXIO) { -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
